link_to_function does not react to click in rails 3.1.0 & simple_form

304 views Asked by At

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.

1

There are 1 answers

5
Dave Newton On BEST ANSWER

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.