Why I have to put all the script to index.html in jquery mobile

后端 未结 3 1307
闹比i
闹比i 2020-11-22 07:02

I have used $.mobile.changepage to do the redirect in my phonegap+jquerymobile projects. However what makes me confused is that I need to put the script of all the pages to

3条回答
  •  无人及你
    2020-11-22 07:22

    Unlike normal ordinary HTML pages, jQuery Mobile uses ajax technology when navigating between pages. So make sure to import all your JS files and libraries in all your html pages.

    If you notice closely you will see that JS files from previous page is taken into consideration when loading the second page. But if you force rrefresh the current page then the js files of the current page will be effective.

    So as I said earlier make sure to import the js files in all the html files.

    Also no need to call deviceready, use following syntax to call your page specific js functions

    $(document).on('pageshow', '#YourPageID', function(){
        // Your code goes here
    });
    

提交回复
热议问题