gpt4 book ai didi

javascript - 在 JQM 数据 Angular 色 ='page' onload 上加载 JavaScript

转载 作者:行者123 更新时间:2023-12-02 19:30:25 27 4
gpt4 key购买 nike

有什么方法可以在 JQM“页面”加载上运行 JavaScript 吗?我有一个图表应该出现在 JQM 页面的单个页面中,但如果我将其加载到 document.ready 上,它只会显示我是否刷新该特定 JQM“页面”。如果我在任何其他“页面”上刷新,我的图表将无法加载。是否有某种 onload("#myDiv") 函数可以解决此问题?我所做的唯一的其他解决方案是制作一个按钮,用户可以单击该按钮来加载图表,但这似乎是不必要的,应该能够自动加载它。

$(document).ready(function()
{
$('#wordcloud').bind('pageinit', function() {
alert("works!");
});
})

上面的代码有点接近吗?但我没有收到警报。

还在 div、头部(内部和外部)中尝试了此代码document(ready)

$('#wordcloud').live('pagebeforeshow', function() {
alert(2);
});

最佳答案

正如 doc 中指出的那样,如果您想在 jQueryMobile 页面加载上执行某些操作,则必须使用 $(document).bind('pageinit')

pageinit

Triggered on the page being initialized, after initialization occurs. We recommend binding to this event instead of DOM ready() because this will work regardless of whether the page is loaded directly or if the content is pulled into another page as part of the Ajax navigation system.

关于javascript - 在 JQM 数据 Angular 色 ='page' onload 上加载 JavaScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11557236/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com