PDA

View Full Version : Error when using Sencha in Phonegap notification callback function



aguerra10
18 Nov 2011, 12:28 PM
Hi all,

I am showing a confirm notification using PhoneGap with a callback function that uses some sencha basic code. However when this Sencha code runs, it is sending an error.

"Error in success callback: com.phonegap.notification0 = TypeError: 'undefined' is not a function"

This happens when "this.getMainView();" or any of the other lines inside logout method is called.

However, If I call the logout function without showing the notification, it works.

Can anybody help me?

Thanks!!

Here is the code involved :



init: function() {
this.setListeners();
},

setListeners:function(options) {
this.control({
'#settingsScreen button[id = logoutButton]': {
tap: this.showLogout,
},
});
},

showLogout: function() {
navigator.notification.confirm('Are you sure you want to logout?', this.onConfirm, 'Logout?', 'No,Yes');

},

logout: function() {

var mainView = this.getMainView();
var mainController = this.getController('MainController');
var launchscreen = this.getLaunchscreen();
mainController.setAnimationForward(mainView);

mainView.setActiveItem(launchscreen);
window.location.href = window.location.href;

},

onConfirm: function(buttonIndex) {
if (buttonIndex === 2) { this.logout();
}
},

rdougan
18 Nov 2011, 2:24 PM
Are you sure it is even getting to logout? It looks like it could be a scope issue to me. I experienced this before.


showLogout: function() {
var me = this,
fn;

fn = function() {
me.onConfirm();
};

navigator.notification.confirm('Are you sure you want to logout?', fn, 'Logout?', 'No,Yes');
}

aguerra10
21 Nov 2011, 5:00 AM
That did the trick!!

I am new here in the forum and I really appreciate the help I've received so far.

Thank you rdougan!!