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

Popular posts from this blog

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -

javascript - Iterate over array and calculate average values of array-parts -

jQuery Ajax Render Fragments OR Whole Page -