简体   繁体   中英

Initialize JS Scripts on jQueryMobile Page

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM