Msencenb
Msencenb

Reputation: 5104

Render partial with collection with jQuery

Let's say I have an index.js.erb file that gets called remotely. How would I render a partial with a collection and then have jQuery display it on the page.

I'm thinking something along the lines of this (that actually works):

$('#eventlist').html("<%= escape_javascript(render :partial => \"memorylist\", :collection => @memories) %>");

Upvotes: 1

Views: 726

Answers (1)

Chris Barretto
Chris Barretto

Reputation: 9529

Looks good to me. Only thing I might change is using single quotes on the inside to make it a little more readable:

$('#eventlist').html("<%= escape_javascript(render :partial => 'memorylist', :collection => @memories) %>");

Upvotes: 3

Related Questions