Ruby on Rails 中的 RJS 错误
为什么会这样:
<%= update_page_tag do |page|
page["femenino"].hide
end %>
生成这个?
<script type="text/javascript">
//<![CDATA[
try {
$("femenino").hide();
} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('$(\"femenino\").hide();'); throw e }
//]]>
</script>
我的 DIV 的 ID 为“femenino”,update_page_tag 位于 DIV 之后,它可以工作,但我不喜欢在源代码中查看该错误。
谢谢
Why does this:
<%= update_page_tag do |page|
page["femenino"].hide
end %>
Generates this?
<script type="text/javascript">
//<![CDATA[
try {
$("femenino").hide();
} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('$(\"femenino\").hide();'); throw e }
//]]>
</script>
I have the DIV with ID "femenino", the update_page_tag is located after the DIV and it works but I dont like to look at that error in the source code.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当启用 config.action_view.debug_rjs 选项时,rails 会将 PrototypeHelper 生成的大部分 javascript 包装在 try/catch 块中。
默认情况下,
config.action_view.debug_rjs
仅在开发模式下启用,因此,如果您在生产中看到此情况,请检查您的config/environments/production.rb
文件。When the
config.action_view.debug_rjs
option is enabled, rails will wrap most of the javascript generated from PrototypeHelper in a try/catch block.By default
config.action_view.debug_rjs
is enabled in development mode only, so check yourconfig/environments/production.rb
file if you're seeing this in production.