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

I am doing a phonegap / cordova project. I created a skeleton project using the command line, as guide suggests creating a new android project / phonegap.

In the created index.html file there is a piece of app.initialize() code, and the code comes from the index.js file.

My question is should I have this piece of code in all my html files, since I will use jQueryMobile to work with the interface, I may need several html files.

 var app = { // Application Constructor initialize: function() { this.bindEvents(); }, // Bind Event Listeners // // Bind any events that are required on startup. Common events are: // 'load', 'deviceready', 'offline', and 'online'. bindEvents: function() { document.addEventListener('deviceready', this.onDeviceReady, false); }, // deviceready Event Handler // // The scope of 'this' is the event. In order to call the 'receivedEvent' // function, we must explicity call 'app.receivedEvent(...);' onDeviceReady: function() { app.receivedEvent('deviceready'); }, // Update DOM on a 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); } }; 
+7
source share
1 answer

Since all pages are invoked through Ajax calls, theoretically you do not need to add this line to all your pages. But in some cases, you may need to add it, for example, if there is a possibility that a particular page cannot be called from an ajax call, or the user, for some strange reason, gets to this page instead of your index page.

+3
source

All Articles