ruby-on-railsajaxlink-to-remote

Alternative for link_to_remote's :update in rails3


Im in the process of converting my rails code which developed in version 2 to rails 3.

Earlier I used link_to_remote function to create a link.In that I displayed the page on a div field using ':update' option.

 <%= link_to_remote @processes_tree[x]["name"],:update => "toprightdiv", :url => { :action => "editproduct", :id => @processes_tree[x]["id"]}%>

Now In rails the link_to_remote is not available ,So I used link_to.But in it the :update option is not available.

So I am not able to show the page in the div field.When ever I click the link a new page getting displayed for the link.Is there any alternative way available i n rails3.Please help me to solve the issue.


Solution

  • This is a very general question regarding unobtrusive javascript in rails (googling that phrase would get all you need to know).

    Generally you need to use link_to and set :remote to true. Then do the update by handling the response in a .js view or equivalent.

    You may also benefit from this screencast demonstrating the rationale for the change:

    http://railscasts.com/episodes/205-unobtrusive-javascript