在 jQueryMobile 页面上初始化 JS 脚本

发布于 2024-11-30 23:44:07 字数 510 浏览 1 评论 0原文

我正在使用 jQueryMobile 1.0 Beta 2 开发一个单页应用程序,并在 iOS 4.3.5 Mobile Safari 上进行测试。

正如我们在这里看到的: http://jquerymobile.com/test/docs/api/events.html

jquery mobile api 对于使用 ajax 调用初始化脚本的新方法非常具体。我正在使用 jquery mobile api 中的 pageCreate() 事件来初始化我的脚本:

$('.ui-page').live('pagecreate',function(event){
  //my js init codes
});

但不知何故,它不是那么有效,并且我在未初始化的关键视图之一上遇到了麻烦。

任何帮助表示赞赏。

谢谢。

I am working on a single-page app using jQueryMobile 1.0 Beta 2 and testing on iOS 4.3.5 Mobile Safari.

As we can see here:
http://jquerymobile.com/test/docs/api/events.html

The jquery mobile api is very specific on the new way to initialize scripts with the ajax calls. I am using the pageCreate() event from the jquery mobile api to initialize my scripts:

$('.ui-page').live('pagecreate',function(event){
  //my js init codes
});

But somehow, it is not so effective and I am having trouble on one of my key views which doesn't initialize.

Any help is appreciated.

Thank you.

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

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

发布评论

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

评论(1

不喜欢何必死缠烂打 2024-12-07 23:44:07

尝试使用 pageshow 事件:

    $('.ui-page').live('pageshow', function(event) {
        // js init codes
    });

这在我的应用程序中对我有用。希望它对你有用。

Try using the pageshow event:

    $('.ui-page').live('pageshow', function(event) {
        // js init codes
    });

This is working for me in my app. Hope it works for you.

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