当 ajax 加载时,在另一个函数之后运行一个函数
我遇到了一个严重的问题,阻止我在 Prototype 窗口中运行 jQuery,因为它们是使用 Ajax 加载的。
我认为解决方案是在 Prototype UI.Window 获取 Ajax 内容后立即以某种方式调用 jQuery 函数,我和我的代码还有希望吗? :(
这是原型函数:
function openApps() {
new UI.Window({theme: "ultra_dark",
width: 1170,
height: 630,
superflousEffects: superflousEffects}).center().show().setAjaxContent('template/win_apps.php', {
method: "GET",
onCreate: function() {
this.header.update("Applications");
this.setContent('<div class="message">Please wait...</div><div class="spinner"></div>');
}
});
}
现在我正在考虑类似的事情:
window.lines = function() {
jQuery(".line").peity("line");
};
jQuery.click(lines);
但我不知道放置它的正确方法在哪里以及它是否会起作用(我打赌它不会。)
基本上我需要 jQuery(".line").peity("line");
如果有人有其他建议,请在 Ajax 获取的内容上运行 - 不客气,
谢谢。
I'm having a heavy problem that stops me from running jQuery inside of Prototype windows because they are loaded using Ajax.
I think that the solution would be to somehow call the jQuery function immediately after the Prototype UI.Window
has fetched the Ajax content, is there any hope for me and my code? :(
This is the Prototype function:
function openApps() {
new UI.Window({theme: "ultra_dark",
width: 1170,
height: 630,
superflousEffects: superflousEffects}).center().show().setAjaxContent('template/win_apps.php', {
method: "GET",
onCreate: function() {
this.header.update("Applications");
this.setContent('<div class="message">Please wait...</div><div class="spinner"></div>');
}
});
}
Now i was thinking about something like:
window.lines = function() {
jQuery(".line").peity("line");
};
jQuery.click(lines);
But i have no idea where is the proper way to place it and if it will work (my bet is that it wouldn't.)
Basically i need jQuery(".line").peity("line");
to run on the Ajax fetched content if someone has some other suggestions - you are welcome.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定这是否有意义,但您可以监听 ajaxStop (Jquery) 事件;当所有 Ajax 请求完成时触发
Not sure if it makes sence, but you can listen on The ajaxStop (Jquery) event; it 's triggered when all Ajax requests are finished
我不了解 Prototype.js,但我知道 ajax 是如何工作的。所以看看你是否可以在这里使用类似 ajax 的 success 函数的东西,这样你就可以首先使用 ajax 的响应在 DOM 上渲染数据,然后在其上应用 jquery。您无法将 jquery 代码应用于尚未附加到 DOM 的元素
I have no knowledge of Prototype.js but i know how ajax works. So just see if you can use something like a success function of ajax here, so that you can render the data on your DOM first using the response from ajax and then apply jquery on it. You can't apply jquery code on elements that haven't yet been attached to the DOM