I have a Rails 3.1 application where the view has the following link:
<%= link_to("Answer Question",question_ajaxans_path(@question.id),:remote=>true)%>
Which has the controller option:
def answer
@answer = Answer.new(:question_id=>params[:question_id])
respond_to do |format|
format.js
end
end
Which renders this partial code:
alert("it worked");
$("div#answers").append(<%= escape_javascript(render :partial=>"answers/form") %>);
Firebug shows the partial is rendered, and I have double checked my view to verify that a div with an id of answers was there.
This turorial , http://railscasts.com/episodes/205-unobtrusive-javascript?view=asciicast, seems to show that it should just load and so do other ones I find on the web. But, I don’t think that is the case.
Thanks to this post http://rails3stuff.posterous.com/#!/59899595 I realized that my problem resides in .append(). I didn’t wrap the interior in quotes.