开发者

Render partial with collection with jQuery

开发者 https://www.devze.com 2023-03-20 09:07 出处:网络
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.

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):

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


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) %>");
0

精彩评论

暂无评论...
验证码 换一张
取 消