1

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.

user938363
  • 9,990
  • 38
  • 137
  • 303

1 Answers1

1

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.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • Do you have new api definition about link_to_function in rails 3.1.0 and after? I read an online api definition about link_to_function and noticed the green bar stopped at rails 3.0.9. But I did not find any info about link_to_function in rails 3.1.0 and after. thanks. – user938363 Jan 12 '12 at 20:51
  • @user938363 apidock.com seems to have 3.1, although I may have misread. – Dave Newton Jan 12 '12 at 21:14
  • @user938363 (That said, IMO it's really important to have the source of whatever version(s) you're using local and available--it's often the only real documentation of value.) – Dave Newton Jan 12 '12 at 21:54
  • There is a note for the api. It used the block. Here is the code: link_to_function("Show me more", nil, :id => "more_link") do |page| page[:details].toggle "Blind" page[:more_link].replace_html "Show me less" end – user938363 Jan 13 '12 at 01:35
  • @user938363 So? The note is from 2008, ~3.5 years ago. Look at the source. – Dave Newton Jan 13 '12 at 01:37