I'm trying to create an ajax-based comment form which will update my comments list when submitted. Pretty basic stuff.
I have a partial comments/_single.html.haml
which has a single <li>
tag with basic comment info and here is my comments/create.js.erb
file (actually these are three different test files merged into one to show you what my problem is):
$('#comments ul.comments').append("<%= render :partial => 'comments/single', :locals => { :c => @comment } %>");
$('#comments ul.comments').append("<%= render :partial => 'comments/foobar' %>");
$('#comments ul.comments').append("foobar");
alert('foobar');
The content for comments/_foobar.html.haml
is just foobar
, no html inside.
My problem is that first two lines doesn't work. There are no errors in my dev server console, object inspector says that comment code was returned correctly but they are not added to my comments list. The third line works fine and so the fourth one. It looks like there are some problems with using render
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…