Garth Gutenberg created CB-6436:
-----------------------------------
Summary: deviceready not firing on iOS 7.1 with Sencha Touch 2.3.1
Key: CB-6436
URL: https://issues.apache.org/jira/browse/CB-6436
Project: Apache Cordova
Issue Type: Bug
Components: CordovaJS
Affects Versions: 3.4.0
Environment: iOS 7.1
iPhone 4 + Simulator
Reporter: Garth Gutenberg
The {{deviceready}} event never fires due to a JS error on iOS 7.1 with Cordova
3.4.x. This is the same issue as reported in CB-5488.
The console error/trace is:
{quote}
[Error] TypeError: 'null' is not an object (evaluating
'document.body.appendChild')
createExecIframe (cordova.js, line 833)
iOSExec (cordova.js, line 1009)
getInfo (device.js, line 74)
(anonymous function) (device.js, line 48)
fire (cordova.js, line 750)
(anonymous function) (cordova.js, line 1195)
f (cordova.js, line 622)
fire (cordova.js, line 750)
(anonymous function) (cordova.js, line 1183)
onScriptLoadingComplete (cordova.js, line 1369)
scriptLoadedCallback (cordova.js, line 1386)
{quote}
The fix that I've applied to cordova.js (from 3.4.1-0.1.0) is to replace lines
1627-1630.
Old:
{code:JavaScript}
window.cordova = require('cordova');
// file: src/scripts/bootstrap.js
require('cordova/init');
{code}
New:
{code:JavaScript}
var documentBodyIntervalID = window.setInterval( function() {
if ( null == document.body ) {
return;
}
window.clearInterval( documentBodyIntervalID );
window.cordova = require('cordova');
// file: src/scripts/bootstrap.js
require('cordova/init');
}, 100 );
{code}
I'm just checking document.body every 100ms to make sure that it's not null
before triggering the rest of the Cordova script. I suspect it may have to do
with Sencha Touch 2.3.1, but I can't guarantee it. I can provide an Xcode
project if needed.
--
This message was sent by Atlassian JIRA
(v6.2#6252)