How to initialize pages in jquery mobile? pageinit not firing

后端 未结 11 1217
死守一世寂寞
死守一世寂寞 2020-11-29 01:44

What\'s the right way to initialize objects on a jquery mobile page? The events docs say to use \"pageInit()\" with no examples of that function, but give exam

相关标签:
11条回答
  • 2020-11-29 02:09

    Turns out this is a bug in 1.0b3 that is fixed in the current head. So if you want a fix now, you gotta grab the latest from git. Or wait for the next release.

    0 讨论(0)
  • 2020-11-29 02:09

    Try this:

    $('div.page').live('pageinit', function(e) {
        console.log("Event Fired");
    });
    
    0 讨论(0)
  • 2020-11-29 02:14
    jQuery(document).live('pageinit',function(event){
        centerHeaderDiv();
        updateOrientation();
        settingsMenu.init();
        menu();
        hideMenuPopupOnBodyClick(); 
    })
    

    This is working now. Now all page transitions and all JQM AJAX functionality would work along with your defined javascript functions! Enjoy!

    0 讨论(0)
  • 2020-11-29 02:14

    The events don't fire on the initial page, only on pages you load via Ajax. In the above case you can just:

    <script>
      $(document).ready(function() {
          alert("This happens");
      });
    </script>
    
    0 讨论(0)
  • 2020-11-29 02:18

    I had to put the script in the HTML page section which to me is a bug. It is loaded normally in a browser (not via AJAX) and all on a single page including javascript. We're not supposed to have to use document ready.

    0 讨论(0)
提交回复
热议问题