Mootools 请求更改 JavaScript 代码?

发布于 2024-09-08 22:18:45 字数 469 浏览 1 评论 0原文

因此,我计划通过从另一个页面获取页面的内容来动态更改页面的内容。

为此,我使用了 Mootools 的 Request 类:

var tabContent = new Request({
    url: 'foo/bar/baz.php',
    onSuccess: function(data) {
        $('tab_container').innerHTML = data;
    }
}).send();

在任何情况下,HTML 都能正常获取,并且顺利返回。但是,我想向那些获取的元素(准确地说是 Fx.slide)添加一些事件,这需要在请求的文件中包含一些 js。

检查返回的数据后,javascript 完好无损。然而,它并没有出现在最终产品中。也就是说,在接收数据和渲染数据(通过innerHTML 位)之间的某个地方,似乎 javascript 由于某种原因已被删除。

嗯。

So I am planning on dynamically changing a page's content by fetching it from another page.

To do so, I used Mootools' Request class:

var tabContent = new Request({
    url: 'foo/bar/baz.php',
    onSuccess: function(data) {
        $('tab_container').innerHTML = data;
    }
}).send();

In any case, the HTML is fetched fine, and returns without a hitch. However, I'd like to add some events to THOSE fetched elements (Fx.slide, to be precise), and that requires some js to be included in the requested file.

Upon inspection of the returned data, the javascript is intact. However, it does not show up in the final product. That is, somewhere in between having received the data, and rendering the data (via the innerHTML bit) it seems as though the javascript has been excised out for some reason.

Hm.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

话少情深 2024-09-15 22:18:45

evalScripts: true 添加到请求选项,然后将脚本包含在响应底部的简单 块中。

add evalScripts: true to the Request options, then include the script in a simple <script></script> block at the bottom of the response.

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