开发者

How to handle link_to_function in rails3

This is my code

<%= link_to_function ("Add another url", :id=> "add_another_url_link_id") do |page| 
                      page.insert_html :bottom ,:add_another_url, :partial =>'add_another_url', :locals => {:object =>Url.new, :url => section}
                    end%>

Here i am showing add_another_url partial under the bottom of add_another_ur div. I have a list. At the end of row i am showing this link. When i click the link that will show form under the row. But when i click the link that is showing the form unde开发者_如何转开发r the first row only. I want to show the form for corresponding row. (I don't know how to use 'this' in this place)

Can Anyone help me.


I assume you generate this link for every row in your list. This is a bad idea because it will generate the same element id (add_another_url_link_id) for every row which is not valid html.

You should either generate individual ids:

<%- @items.each do |item| %>
  <%= link_to_function "Add another url", :id => "add_url_for_item_#{item.id}" do |page| %>
    ...

And use the specific id to find the relevant row.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜