jquerymobile: incluye .js y .html
En mi aplicación, estoy usando más de una página html para mostrar el contenido y cada página tiene su propio archivo .js. Cuando llamo a la página html, también se incluye el archivo .js. En el .js, estoy usando$('div').live('pageshow',function(){})
. Estoy llamando al archivo html desde.js(using $.mobile.changePage("htmlpage"))
.
Mi problema: considere, tengo dos archivos html. Se llama al archivo second.html con one.js. cuando muestro el second.html, esa vez one.js se vuelve a cargar de nuevo. Recibo la alerta "one.js" y luego "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");
});
Nota: Cuando muestro adelante.html esa vez, los siguientes archivos se vuelven a cargar (one.js, second.js, third, js y 4th.js. Pero necesito a 4th.js solo). Traté de usar $ .document.ready (function () {}); pero esa vez .js no llamó.