link_to_function 对 Rails 3.1.0 & 中的单击没有反应简单形式
以下是 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 后缺少链接的任何想法?谢谢。
Here is the code in rfqs/_form_new.html.erb to add a selection box for standard.
<%= 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 %>
The html source code has # after href and cause no reaction for clicking the link.
<a href="#" onclick="; return false;">Add Std</a>
The _standards.html.erb partial looks like:
<%= f.association :standards, :collection => Standard.active_std.all(:order => 'name'), :label_method => :name, :value_method => :id %>
Any thoughts about missing link after href? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不相信 3.1 的
link_to_function
的工作方式与旧版本相同;我没有在源代码中看到任何使用块的内容。这似乎与使用不引人注目的 JavaScript 是一致的。与接受块相关的 Rails 拉取似乎与链接文本更相关,而不是注入 JS。
I don't believe 3.1's
link_to_function
works the same way as older versions; I don't see anything in the source that utilizes a block.This seems in keeping with using unobtrusive JavaScript. The Rails pulls related to accepting a block seem more related to link text rather than injecting JS.