How to render a partial and and a javascript file in the same time in Rails ?
- by master2004
Hi.
My main intention is to keep the functionality independent form the Javascript, to have it gracefully degradable. Maybe I am trying to go where I want the wrong way but the main idea is:
there are some jQuery UI tabs and when the user presses a link, a new tab is added corresponding to that action
$("#tabs").tabs('add', "/groups", "My Groups");
the controller identifies the AJAX request and renders only the partial for that tab
if request.xhr?
render :partial => "index_tab"
end
at this point I would like the Javascript file associated with the /groups/index action to be executed as well, meaning the index.js.erb file in the groups folder.
because of the "only one render" rule I couldn't think of a nice way to do it and I am in need of a fast solution.
Thank you for any suggestions you might have.