javascript - Do I need to add app.initialize() in all my html files in a cordova/phonegap project -


i making phonegap/cordova project. created skeleton project using command line, guide suggests making new android/phonegap project.

in index.html file created there piece of code app.initialize(), , code comes file called index.js.

my question is, have have piece of code in html files, since using jquerymobile front-end, might need have several html files.

var app = {     // application constructor     initialize: function() {         this.bindevents();     },     // bind event listeners     //     // bind events required on startup. common events are:     // 'load', 'deviceready', 'offline', , 'online'.     bindevents: function() {         document.addeventlistener('deviceready', this.ondeviceready, false);     },     // deviceready event handler     //     // scope of 'this' event. in order call 'receivedevent'     // function, must explicity call 'app.receivedevent(...);'     ondeviceready: function() {         app.receivedevent('deviceready');     },     // update dom on received event     receivedevent: function(id) {         var parentelement = document.getelementbyid(id);         var listeningelement = parentelement.queryselector('.listening');         var receivedelement = parentelement.queryselector('.received');          listeningelement.setattribute('style', 'display:none;');         receivedelement.setattribute('style', 'display:block;');          console.log('received event: ' + id);     } }; 

since pages called through ajax calls, in theory don't need add line in pages. in cases might want add it, example if there might chance particular page might not called ajax call, or user strange reason lands on page, instead of index page.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -