簡體   English   中英

時間軸上等於window.load事件的jquery移動加載事件

[英]jquery mobile load event that is equal to window.load event over the timeline

使用jquery mobile 1.1.0,許多設備可以具有不同的屏幕高度,以便在執行時填充空白空間:content_height = screen_height-header_height-footer_height

唯一會等到所有內容加載完畢以計算實際高度的事件是

$(window).load

我的問題:因為我使用ajax導航系統,所以window.load僅會觸發一次,而我測試了許多負載轉移事件:

$(document).bind('pagechange', func..)
$(document).bind('pageload', func..)

等等..

我的問題:是否有一個jQuery移動事件會在每次加載頁面時觸發,並且觸發時間足以加載大小? 或在加載內容時觸發方法的任何其他方式。

小提琴http : //jsfiddle.net/ca11111/CAtWG/

如果您想在頁面完全加載后做一些事情:
在您的html中:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script type="text/javascript">
$(document).bind("mobileinit", function(){
    //$.mobile.loadingMessageTextVisible = true;
    // set global config of jquery mobile here
});
</script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
<script type="text/javascript"  src='test.js'></script>

然后放入您的test.js文件:

$("#Mypage1").live("pagecreate", function() {
     //do stuff when Mypage1 is created 
     // happens once if you don't explicitly refresh
      alert("Mypage1 created");
     $("#mydiv").height($("body").height() - 50);
});

$("#Mypage1").live("pageshow", function() {
     //do stuff when Mypage1 is shown
     // happens multiple times, as soon as you go to Mypage1 from other pages
     alert("Mypage1 visible");
});

您可能還在尋找方向更改事件,因此添加:

$(window).bind('orientationchange', _orientationHandler);

if(event.orientation){
    if(event.orientation == 'portrait'){
              //do something
    }
    else if(event.orientation == 'landscape') {
                //do something
    }
}

如果您觸發了自己的ajax請求,並且想要修改html,只需在回調中執行以下操作:

$("#Mypage1").trigger("pagecreate");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM