In my application, I use more than an html page to display content, and each page has its own .js file. When I invoke the html page, then the .js file is also included. In .js, I use $('div').live('pageshow',function(){}) . I am calling an html file from. js(using $.mobile.changePage("htmlpage")) .
My problem: consider, I have two html files. The second.html file is called with the name one.js. when i show second.html, then one.js time restarts again. I get the warning "one.js", then "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"); });
Note. When I show in the future. html, the following files are reloaded (one.js, second.js, third, js and 4th.js. But I only need the fourth.). I tried using $ .document.ready (function () {}); but this time .js did not call.
jquery jquery-mobile
Finder
source share