Ruby on Rails 中的 RJS 错误

发布于 2024-09-14 00:31:22 字数 451 浏览 4 评论 0原文

为什么会这样:

    <%= 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

左岸枫 2024-09-21 00:31:22

当启用 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 your config/environments/production.rb file if you're seeing this in production.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文