Search code examples
javascriptjqueryruby-on-railsrenderpartial

Adding effect to Partial renders using jQuery in Rails


In rails, whenever I render a partial, it just displays with no effect. Is it possible to apply a jQuery effect say a slideDown() whenever a render partial is called in rails?


Solution

  • Don't you mean slideDown() ?

    Do you want this to happen after a regular page request or upon rendering an Ajax call?

    If it's a regular request you might want to put in your jQuery code in the application.js file.

    If it's in upon rendering an ajax call it would then be in the view_name.js.erb file.

    Editing to answer comment request for some code sample. So you put this in your view_name.js.erb

    $("#div-name").replaceWith("thanks for your vote").hide().slideDown(300);
    

    So many different things you could do in there