複数ページの HTML Web ページで jquery モバイル ページ イベントを理解しようとしています。
index1.html 内で window2 に移動しようとすると、ページ イベントがトリガーされ、遷移が発生します。
ただし、index1.html から index3.html に移動しようとすると、index3.html のページ イベントがトリガーされず、ページ遷移が発生します。
index3.html の href に data-ajax="false" を追加してみたところ、page3.html のページイベントが発生しています。ただし、移行は行われていません。
誰かが私を理解するのを手伝ってくれますか 1) なぜイベントが発生しないのですか? 2) data-ajax="false" の使用に関する問題
以下は、私がナビゲートしようとしているページです
index1.html:
<!DOCTYPE html>
<html>
<head>
<meta name=viewport content="user-scalable=no,width=device-width" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
</head>
<body>
<div data-role="page" id="home">
<div data-role="header">
<h1>Home</h1>
</div>
<div data-role="content">
<p> Window content 1 </p>
<a href="#win2"> Window 2 (into the DOM) </a>
<br /><br />
<a href="index3.html" data-transition="pop" >
Window 3 in index3.html (data-dom-cache=false) </a>
<br /><br />
<br /><br />
</div>
</div>
<div data-role="page" id="win2" data-add-back-btn="true">
<div data-role="header">
<h1>Window 2</h1>
</div>
<div data-role="content">
<p> Window content 2 </p>
</div>
</div>
</body>
</html>
$(document).bind ("pagebeforeload", function (event, data)
{
alert ("pagebeforeload data.url = " + data.url);
});
$(document).bind ("pageload", function (event, data)
{
alert ("pageload data.url = ");
});
$(document).bind ("pageloadfailed", function (event, data)
{
alert ("pageloadfailed data.url = " + data.url);
});
$("#home").on ("pagebeforecreate", function (event)
{
alert ("pagebeforecreate id=" + this.id);
});
$("div:jqmData(role=page)").on ("pagecreate", function (event)
{
alert ("pagecreate id=" + this.id);
});
$("div:jqmData(role=page)").on ("pageinit", function (event)
{
alert ("pageinit id=" + this.id);
});
$("div:jqmData(role=page)").bind ("pagebeforeshow", function (event, ui)
{
alert("pagebefore show");
});
$("div:jqmData(role=page)").bind ("pageshow", function (event, ui)
{
alert("pageshow");
});
$("div:jqmData(role=page)").bind ("pagebeforehide", function (event, ui)
{
alert("pagebeforehide");
});
$("div:jqmData(role=page)").bind ("pagehide", function (event, ui)
{
alert("pagehide");
});
**index3.html**
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=Content-Type content=text/html;charset=iso-8859-1 />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
</head>
<body>
<div data-role="page" id="win3" data-add-back-btn="true">
<div data-role="header">
<h1>Window 3</h1>
</div>
<div data-role="content">
<p> Window content 3 </p>
</div>
</div>
</body>
</html>
<script>
$("div:jqmData(role=page)").bind ("pagebeforeshow", function (event, ui)
{
alert("pagebefore show3");
});
$("div:jqmData(role=page)").bind ("pageshow", function (event, ui)
{
alert("pageshow3");
});
$("div:jqmData(role=page)").bind ("pagebeforehide", function (event, ui)
{
alert("pagebeforehide3");
});
$("div:jqmData(role=page)").bind ("pagehide", function (event, ui)
{
alert("pagehide3");
});
</script>