下面是rfqs/_form_new.html.erb中添加标准选择框的代码。
<%= 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之后缺失的链接有什么想法吗?谢谢。
发布于 2012-01-12 22:57:19
我不相信3.1的link_to_function和老版本的工作方式是一样的;我没有看到任何使用块的in the source。
这似乎与使用不显眼的JavaScript保持一致。与接受块相关的Rails拉似乎更多地与链接文本相关,而不是注入JS。
https://stackoverflow.com/questions/8795383
复制相似问题