【发布时间】:2010-03-20 22:04:35
【问题描述】:
好的,我有这个问题,我正在尝试使用 Jquery 加载部分以替换列出的对象。
index.html.erb
<div class="style_image_<%= style.id %>" > <%=link_to image_tag(style.cover.pic.url(:small)), style %></div>
加载显示:
$(function() {
$(".style_image_<%= style.id %> a").click(function() {
$(".style_image_<%= style.id %>").html("loading... ")
$(".style_image_<%= style.id %>").html("<%= escape_javascript(render("show")) %>")
$.get(this.href, null, null, "html");
return false;
});
});
_show.html.erb:
<%=link_to image_tag(style.cover.pic.url(:normal)), style %>
我收到此错误:
missing ) after argument list
[Break on this error] $(".style_image_<%= style.id %>").htm...scape_javascript(render("show")) %>")\n
这里我的代码有两个问题,第一个是点击函数不是针对 .style_image_ .... 即 (.style_image_42) 如果我将 css 目标替换为 42 而不是_style.id 点击目标有效; 这是为什么?
无论有没有这种变化,_show 部分都不会呈现,并且会出现上述错误。
Javascript 不是很好,任何帮助都会很棒!
附言
我真正想要的效果就像那些超酷的cargo主题之一:http://cargocollective.com/publikspace
谢谢丹!
【问题讨论】:
标签: javascript jquery ruby-on-rails