rendering partials inside Javascript code
When rendering partials inside Javascript code, you should use the escape_javascript method, like so
$('#comments ul.comments').append("<%= escape_javascript render(:partial => 'comments/single', :locals => { :c => @comment }) %>");
This method is aliased as j, so you can also do this
$('#comments ul.comments').append("<%= j render(:partial => 'comments/foobar') %>");
Written by rocLv
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails partial js
Authors
Related Tags
#rails partial js
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#