stewart715
stewart715

Reputation: 5647

rails index.js.erb not loading

I am attempting to do some ajax for pagination but I canno get index.js.erb to load or be recognized in any way. I'm following railscast 240:https://github.com/ryanb/railscasts-episodes/blob/master/episode-240/store/app/views/products/_products.html.erb

I am using the code below:

index.js.erb

$("#products").html("<%= escape_javascript(render("products")) %>");

The request seems to go through properly, but the HTML isn't loading. Nothing changes (no errors though)

Upvotes: 0

Views: 1665

Answers (2)

stewart715
stewart715

Reputation: 5647

It was because I had format |do| in my controller without format.js. Sorry guys!

Upvotes: 2

Try using:

<%= escape_javascript(render(:partial => 'products/products')) %>

instead of

<%= escape_javascript(render("products")) %>

Upvotes: 0

Related Questions