【发布时间】:2011-07-26 04:50:47
【问题描述】:
我认为下面的代码如下:
<script type="text/javascript">
$(document).ready(function(){
$("#button").click(function(event){
if(false) { //even with if (false), this code is still being executed!
<% if obj %>
<% my_method(obj) %>
<% end %>
$("#button").attr("href","/" + obj.my_path);
}
});
});
</script>
正如您在注释中看到的那样,JavaScript if 语句的条件为假,因此不应执行该块。然而由于某种原因,它就像我的 JS 不存在并且正在调用 ERB 块。为什么会这样? JS 似乎在网站上的其他页面上运行良好。
如果您需要更多信息来帮助解决问题,请尽管提出,我会尽力提供尽可能多的信息。
【问题讨论】:
标签: javascript jquery ruby ruby-on-rails-3 embedded-ruby