I want to pass some arguments to the my Javascript template in Rails3 application What I try with respond_to block is:
respond_to do |format|
format.js({:id=>params[:id]})
end
I also tried:
respond_to do |format|
format.js(params[:id])
end
Am I forced to make id as an instance variable for the js template to use? How to pass variables to the template here?
Does it work?
respond_to do |format|
format.js { render "action", :locals => {:id => params[:id]} }
end
"action" is your action / template name (index, show, etc.)