2012-01-09 17 views
1

以下是rfqs/_form_new.html.erb中用于添加标准选择框的代码。link_to_function对导航栏中的点击没有反应3.1.0&simple_form

<%= simple_form_for @rfq do |f| %> 
    <div id="std"> 
    <%= render :partial => 'standards/standards', :collection => @rfq.standards, :locals => { :f => f } %> 
    </div> 
    <%= link_to_function "Add Std", nil do |page| %> 
    page.insert_html :bottom, :std, :partial => 'standards/standards' 
    <% end %> 
<% end %> 

html源代码在href后有#并且对点击链接没有反应。

<a href="#" onclick="; return false;">Add Std</a> 

的_standards.html.erb部分看起来像:

<%= f.association :standards, :collection => Standard.active_std.all(:order => 'name'), :label_method => :name, :value_method => :id %> 

约HREF后缺少的环节有什么想法?谢谢。

回答

1

我不相信3.1的link_to_function的工作方式与旧版本相同;我没有看到任何使用块的东西in the source

这似乎符合使用不显眼的JavaScript。 Rails涉及接受一个块似乎更多与链接文本相关,而不是注入JS。

+0

你有没有在rails 3.1.0以及之后的版本中有关于link_to_function的新api定义?我阅读了一个关于link_to_function的在线api定义,并注意到在rails 3.0.9停止了绿色栏。但是我在rails 3.1.0以及之后没有找到关于link_to_function的任何信息。谢谢。 – user938363 2012-01-12 20:51:24

+0

@ user938363 apidock.com似乎有3.1,但我可能误读了。 – 2012-01-12 21:14:31

+0

@ user938363(也就是说,IMO拥有本地和可用版本的源码非常重要 - 它通常是唯一真正有价值的文档。) – 2012-01-12 21:54:02