私のアプリケーションでは、コンテンツを表示するために html ページ以上を使用しており、各ページには独自の .js ファイルがあります。HTMLページを呼び出すと、.jsファイルも含まれます。.jsでは、を使用して$('div').live('pageshow',function(){})
います。からhtmlファイルを呼び出しています。js(using $.mobile.changePage("htmlpage"))
.
私の問題: 2 つの html ファイルがあるとします。one.js 内で second.html ファイルが呼び出されます。second.html を表示すると、その時点で one.js が再度リロードされます。「one.js」、次に「second.js」というアラートが表示されます
one.html
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="jquery.mobile-1.0a2.min.css" />
<script src="jquery-1.4.3.min.js"></script>
<script src="jquery.mobile-1.0a2.min.js"></script>
<script src="Scripts/one.js"></script>
</head>
<body>
<div data-role="page">
</div>
</body>
</html>
Second.html
<!DOCTYPE html>
<html>
<head>
<title>Sample </title>
<link rel="stylesheet" href="../jquery.mobile-1.0a2.min.css" />
<script src="../jquery-1.4.3.min.js"></script>
<script src="../jquery.mobile-1.0a2.min.js"></script>
<script type="text/javascript" src="Scripts/second.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="button" id="link" >Second</div>
</div><!-- /page -->
</body>
</html>
one.js
$('div').live('pageshow',function()
{
alert("one.js");
//AJAX Calling
//success result than call the second.html
$.mobile.changePage("second.html");
});
second.js
$('div').live('pageshow',function(){
{
alert('second.js');
//AJAX Calling
//success result than call the second.html
$.mobile.changePage("third.html");
});
注:その時点でforth.htmlを表示すると、次のファイルがリロードされます(one.js、second.js、third、js、およびfourth.js。ただし、fourth.jsだけが必要です)。$.document.ready(function(){}); を使用しようとしました。しかし、その時.jsは呼び出されませんでした。