0
我有问题获取响应脚本在客户端上运行。我对轨道很陌生,我不确定遥控器的真实性。我有以下链接:Rails:js.erb不会在客户端执行?
<%= link_to "#{p.title}", post_path(p), remote: true %>
当我点击它,它引导到表演动作这使得文章的内容,我想分析的内容,以一个div。我show.js.erb看起来像这样
$("#content").html("<h2><%= @post.title %> </h2><p><%= @post.body %></p>");
,当我点击链接,我得到这个响应。
Started GET "/posts/14" for 127.0.0.1 at 2014-01-28 10:51:12 -0800
Processing by PostsController#show as JS
Parameters: {"id"=>"14"}
Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = ? LIMIT 1 [["id", "14"]]
Rendered posts/show.js.erb (0.2ms)
我得到整个jQuery代码看着http响应,但不知何故它不会被执行。
是否存在与网页上的ID'content'标签? – jason328