jQuery mobile popup on pageinit

后端 未结 2 1596
盖世英雄少女心
盖世英雄少女心 2021-01-19 04:55

I want a popup to open as soon as the page loads but seem to be getting stuck with the spinning wheel.

Here is a fiddler to demonstrate the problem any help would be

2条回答
  •  孤独总比滥情好
    2021-01-19 05:38

    The .popup('open') needs the $.mobile.activePage, which is set after the pageinit event. The pagechange event seems to be better for popups.

    This worked for me :

    $(document).on('pagechange',function(event){
        $('#popupBasic').popup('open');
    })​
    

    If you want it just at the first load, use .one :

    $(document).one('pagechange',function(event){
        $('#popupBasic').popup('open');
    })​
    

    See https://github.com/jquery/jquery-mobile/issues/3384

提交回复
热议问题