[ https://issues.apache.org/jira/browse/CB-2094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13542428#comment-13542428 ]
Shazron Abdullah edited comment on CB-2094 at 1/2/13 9:29 PM: -------------------------------------------------------------- I tried it again with a global and local function, with this repro. Either of those works just not this.onDeviceReady. Also if I refer to the variable 'this' was assigned to instead of 'this', it works. Thus it seems it is a scoping issue of 'this' when the function is applied. Repro on iOS 6: 1. Load app 2. Click on Yahoo Remote URL button 3. Click on Home transparent button {code} bindEvents: function() { // global works for CB-2094 x = function() { alert('deviceready global'); } document.addEventListener('deviceready', x, false); // local works for CB-2094 var y = function() { alert('deviceready global'); } document.addEventListener('deviceready', y, false); // local works for CB-2094 function z() { alert('deviceready global'); } document.addEventListener('deviceready', z, false); // this WORKS for CB-2094 document.addEventListener('deviceready', app.onDeviceReady, false); // this does NOT work for CB-2094 document.addEventListener('deviceready', this.onDeviceReady, false); }, {code} was (Author: shazron): I tried it again with a global and local function, with this repro. Either of those works just not this.onDeviceReady. Repro on iOS 6: 1. Load app 2. Click on Yahoo Remote URL button 3. Click on Home transparent button {code} bindEvents: function() { // global works for CB-2094 x = function() { alert('deviceready global'); } document.addEventListener('deviceready', x, false); // local works for CB-2094 var y = function() { alert('deviceready global'); } document.addEventListener('deviceready', y, false); // local works for CB-2094 function z() { alert('deviceready global'); } document.addEventListener('deviceready', z, false); // this does NOT work for CB-2094 document.addEventListener('deviceready', this.onDeviceReady, false); }, {code} > Cordova 2.30 not reliably firing deviceready after reload of local files > ------------------------------------------------------------------------ > > Key: CB-2094 > URL: https://issues.apache.org/jira/browse/CB-2094 > Project: Apache Cordova > Issue Type: Bug > Components: CordovaJS, iOS > Affects Versions: 2.3.0 > Reporter: Bob Moore > Assignee: Shazron Abdullah > Labels: Cordova, deviceready, iOS6 > Fix For: 2.4.0 > > Attachments: index.html, MainViewController.h, MainViewController.m, > MainViewController.xib > > > I've added a semi transparent home button to the MainViewController which > loads the local index.html file within my Cordova 2.30 project. After I've > moved on to a remote page, (may be Cordova enabled, may not) and I return > with the home button, sometimes deviceready does not fire. It may fire a few > times then stop. Once it stops the only way to fix the issue is to send the > app to the background (deviceready will now fire) and return. > This same technique works fine in Cordova 2.20 -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira