Frage

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.

War es hilfreich?

Lösung

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

Andere Tipps

The :update option isn't supported by the new link_to :remote => true.

You will either have to

  • use the legacy plugin
  • write the JS/AJAX yourself instead of using :remote => true
  • use render :update { |page| p.replace_html ... }
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top