jqMobile中pageinit,pagecreate,pageshow等函數的執行順序


常見的共有5個page函數,剛開始有點迷糊的是到底誰先誰后執行。

實驗告訴我們結果:

  
    var temp = '';

    $('body').live('pagechange', function () {  temp += 'pagechange,\n'; console.log (temp); })
    $('body').live('pagecreate', function () { temp += 'pagecreate,\n'; console.log(temp); })
    $('body').live('pageinit', function () {  temp += 'pageinit,\n'; console.log(temp); })
    $('body').live('pageload', function () {  temp += 'pageload,\n'; console.log(temp); })
    $('body').live('pageshow', function () {  temp += 'pageshow,\n'; console.log(temp); })

結果:

顯然,依次是create,init然后是show.

change根據文檔有page切換的時候才會執行。

至於load為什么沒有執行?

原文描述:

Description: Triggered after the page is successfully loaded and inserted into the DOM.

估計ajax啟用后,插入到文檔中時會執行。誰知道追加下?

Pageload也是過時的函數,1.6版中將移除。

The triggering of this event is deprecated as of jQuery Mobile 1.4.0. It will no longer be triggered in 1.6.0.

另外,補充多個page對象時的執行情況:

create和init會執行多次,show只執行一次。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM