フィドル: 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");