jquery - Render partial onclick in rails -
is possible render partial when link clicked?
i have searched google , here can't find useable.
thanks
yes possible. following example uses jquery, tagged :
in view file (the page displayed) :
<%= link_to "display new view", path_to_controller, :remote => true %>
in controller action (path_to_controller), add js response :
respond_to |format| format.js end
and in path_to_controller.js.erb (the js response file) :
$("#your-placeholder-id").prepend('<%= escape_javascript(render 'path/to/view') %>');
hope helps!
Comments
Post a Comment