【发布时间】:2015-05-18 13:34:46
【问题描述】:
我的 rails 项目中的视图 create.js.erb 有一点问题。如果有 id 为 JTBDS 的应答器,我想执行 2 个不同的代码块。
这是我的代码:
if( $("#JTBDS").length ){
$("#T<%= @current_tweet %>").after("<%= escape_javascript(render(:partial => @jtbd) %>"));
$("#E<%= @current_tweet %>").hide();
$(".jtbd_tags").each(function(){
select($(this)[0].name,
"http://localhost:3000/search",
"tag_jtbd");
});
tag_button();
$(".tags").each(function(){
select($(this)[0].name,
"http://localhost:3000/adrs",
"tag");
});
}
else{
$("#T<%= @current_tweet %>").before("<%= escape_javascript(render(:partial => @jtbd, :layout => "jtbd_of_tweet", locals: {jtbd: @jtbd} )) %>");
$("#E<%= @current_tweet %>").hide();
$(".jtbd_tags").each(function(){
select($(this)[0].name,
"http://localhost:3000/search",
"tag_jtbd");
});
}
我不知道为什么,但我有一个错误:语法错误,意外的 kENSURE
我尝试使用 console.log 打印 $("#JTBDS").length 并且我有预期的 0 或 1。
感谢您的帮助
【问题讨论】:
标签: javascript ruby-on-rails ruby erb