-
7 May 2012 7:41 AM #1
Unanswered: How to Trap DeviceReady Event using Cordova .7 and a Command Generated MVC app
Unanswered: How to Trap DeviceReady Event using Cordova .7 and a Command Generated MVC app
I've found that openDatabase returns null on an Android emulator (it's ok on iOS simulator) so I've reasoned I need to run with PhoneGap (is there a non Phonegap way around that problem?).
I'm using the 2.0.1 ST and Cordova 1.7. My app has been generated using the sencha command tool so I don't want to change index.html to include Cordova (which rules out the bear bones example).
So I've added the script using:
Do I need to trap a deviceready event form PhoneGap? If so how and where do I do that?Code:"js": [ { "path": "sdk/sencha-touch.js" }, { "path": "cordova-1.7.0.js", "update": "delta" }, { "path": "app.js", "bundle": true, "update": "delta" } ],
Thanks
-
9 May 2012 3:03 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 435
- Answers
- 3102
Why do you need to trap the deviceready event? The launch method of Ext.application should fire when the deviceready event has fired and all the required ST2 classes have been loaded so you shouldn't need to mess with the deviceready event.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
9 May 2012 8:26 PM #3
package build
package build
Just in case Mitchell didn't answer your question, are you running a package build in Cordova?
You need to run a package build in order to make the app standalone. This will make sure the microloader does the right thing when the app fires up. As Mitchell tersely mentioned, the launch even listens for the deviceready event, so you shouldn't need to do anything else to index.html to make it all work.Code:sencha app build package
My app.json file is similar, but I've got cordova.js first, and no "update":"delta" - just the path. I'm not sure what having the delta update config in there would do, but since you're probably never generating deltas on the cordova script it shouldn't be in there.
-
9 May 2012 10:21 PM #4
In another thread I just saw (http://www.sencha.com/forum/showthre...ng-the-MVC-app) you said :
I wanted to trap the deviceready so that I know Cordova has loaded (because I want to use its openDatabase). Is there another way to know Cordova's initialised?onReady will fire when the HTML document says it is ready (along with the required classes loaded if still using dynamic loading of classes). However, PhoneGap's deviceready event is separate and will fire when PhoneGap is all initialized with any plugins and such. That's why you have to add a listener for the device ready. Basically, when both are fired, then the application/device is ready.
Thanks
-
12 May 2012 12:26 AM #5


Reply With Quote