I'm upgrading a old rails app to 3.1. The app is pretty much working, but I have some ajax functionality I need to update. (If it makes any difference I'm using jquery and coffeescript)

All of the existing ajax functionality was written using render :updates. eg

render :update do |page|
  page.remove "financial_tran_offset_#{params[:ftof_id]}"
  page.replace_html 'details', :partial => 'details', :locals => {:obj => @fire}
end

I think the new preferred way of doing this is to use a respond_to? block to handle the js, but I'm not sure of the best way of handling these different cases.

For the first case (the page.remove) I think with the asset pipe line, I should have an external js in /app/assets/javascripts/ to handle the javascript side (eg the page.remove) but I'm not sure how to pass the parameters to the js file. I'm guessing you can do something like:

respond_to do |format|  
  format.js {:render :js => {:ftof => params[:ftof_id]}
end

but I'm not sure how you could pick this up from inside the js file. Is this right way to pass information to the js? Or is there another method I should be using?

For the second case (the page.replace_html) I think this has been deprecated/removed from 3.1 (according to apidock). I suspect again this should be using the js file in the app/assets/javascript directory, but not sure how I should go about rendering the partial and passing this information into the js.

Thanks for any pointers in this area =)

Edit
Report