简体   繁体   中英

Rerendering partial view at a JavaScript event in Ruby on Rails

I would like to rerender some partial views in Ruby on Rails at a specific JavaScript event. Do you guys know how I could do that?

More specifically, i have some custom in-place-editor fields (from my own helper based on scriptaculous), and I would like to update some partials whenever new values are submitted on the fields. I do have a hookup to a JavaScript callback which will be called when the submit a value in the in-place-editor... but I do not know how to force the partials to reload.

If you already have a callback you can use the great (but sometimes forgotten) remote_function thing:

callback = function() {
  <%= remote_function :update => "div_with_your_partial_id", :url => { :action => "an_action_rendering_your_partial" } %>
}

This will generate the same javascript that is generated whenever your use javascript helpers like link_to_remote .

Not sure how this would look like in Rails 3, though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM