jquery - How to import .js files -


hi developing phonegap application. if use console.log in index.html file prints, if use in file doesn't print. if suppose import files in index.html file like:

<!doctype html> <html> <head> <link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.1.0.css" /> <link rel="stylesheet" href="docs/assets/css/jqm-docs.css" /> <link rel="stylesheet" href="docsdemos-style-override.css" /> <script type="text/javascript" charset="utf-8" src="cordova-1.6.1.js"></script> <script type="text/javascript" src="jquery.mobile/jquery-1.7.2.min"></script> <script type="text/javascript" src="jquery.mobile/jqm.autocomplete-1.4.js"></script> <script type="text/javascript" src="jquery.mobile/jquery.mobile-1.1.0.js"></script> <script type="text/javascript"> console.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); </script> </head> <body> <div data-role="page" id="home" data-add-back-btn="true"> <div data-role="content" > <a href="ui/equity/test.html" data-role="button" id="mybutton">index</a> </div> </div> </body> </html> 

then page display button , print !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!. on click of button shows test.html file like:

<!doctype html> <html> <head> <link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.1.0.css" /> <link rel="stylesheet" href="docs/assets/css/jqm-docs.css" /> <link rel="stylesheet" href="docsdemos-style-override.css" /> <script type="text/javascript" charset="utf-8" src="cordova-1.6.1.js"></script> <script type="text/javascript" src="jquery.mobile/jquery-1.7.2.min"></script> <script type="text/javascript" src="jquery.mobile/jqm.autocomplete-1.4.js"></script> <script type="text/javascript" src="jquery.mobile/jquery.mobile-1.1.0.js"></script> <script type="text/javascript"> console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); </script> </head> <body> <div data-role="page" id="home" data-add-back-btn="true"> <div data-role="content" > <a href="#" data-role="button" id="mybutton">test</a> </div> </div> </body> </html> 

but here doesn't print @@@@@@@@@@@@@@@@@@@@@@@@@@@@ why so?

when have jquery mobile "pages" across different html files, framework grab content of data-role="page" element , inserts current page's dom.

anything not in data-role="page" element ignored. means, scripts in head of first page hit (in case index.html) downloaded , run, why script needs referenced in head of pages.

check pagecreate event here

or

another option force refresh page script in page 2 executed, can setting:

<div data-role="page" id="home" data-add-back-btn="true"> <div data-role="content" > <a href="ui/equity/test.html" data-ajax="false" data-role="button" id="mybutton">index</a> </div> </div> 

added data-ajax="false"


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

c++ - Accessing inactive union member and undefined behavior? -

php - Get uncommon values from two or more arrays -