【问题标题】:evalScripts:true does nothing with Ajax inplace editorevalScripts:true 对 Ajax 就地编辑器不执行任何操作
【发布时间】:2009-12-21 21:39:49
【问题描述】:

我有以下代码来创建就地编辑器:

new Ajax.InPlaceEditor('artifact_pretty_display_date_110_in_place_editor', '/artifacts/set_artifact_pretty_display_date/110', {evalScripts:true})

我更改日期后的响应看起来不错:

Element.update("artifact_pretty_display_date_110_in_place_editor", "12/06/2008");
Element.update("artifact_visible_display_date_110", "12/06/2008");
Element.update("flash_message", "<div class=\"flash_message\" style=\"display:block;\">\r\n            The Document's date was changed to 12/08/2008. \r\n</div>");
Element.update("flash_error", "<div class=\"flash_error\" style=\"display:none;\">\r\n\r\n \r\n</div>\r\n");

唯一的问题是我的就地编辑器字段实际上显示了这个响应,它没有得到评估。就像将 evalScripts 设置为 true 一样,什么都不做。有谁知道为什么会这样?

谢谢!

【问题讨论】:

    标签: javascript prototypejs scriptaculous inplace-editing


    【解决方案1】:

    看看docs,在这种情况下,evalScripts 似乎不是一个有效的选项,我认为您的代码需要看起来像这样:

    new Ajax.InPlaceEditor('artifact_pretty_display_date_110_in_place_editor', '/artifacts/set_artifact_pretty_display_date/110', ajaxOptions:{evalScripts:true})
    

    【讨论】:

    • 我明白这有什么意义,但它实际上对我不起作用
    【解决方案2】:

    这被证明是 Scriptaculous 的 InPlaceEditor 使用 Ajax Updater 而不是 Ajax Request 对象同时还使用 page.replace_html 的问题。如果遇到此错误,可能值得从 scriptaculous 中弹出打开的 controls.js,并确保在 handleFormSubmission 方法中使用了 Ajax Request 对象。如果没有,您可能需要将 htmlResponse 设置为 true,或者根据 scriptaculous 的版本,您可能需要设置一些其他标志。这正是我的问题所在。

    【讨论】:

      猜你喜欢
      • 2023-01-17
      • 1970-01-01
      • 1970-01-01
      • 2010-10-21
      • 2018-08-04
      • 2015-05-30
      • 1970-01-01
      • 1970-01-01
      • 2017-09-11
      相关资源
      最近更新 更多