PDA

View Full Version : Uncaught TypeError: Cannot read property 'dom' of null



2b3pro
7 Mar 2013, 2:34 PM
Here's the sequence of events.
From Ext.NavigationView List, itemtap brings up a Ext.Prompt for a password.
Correct password displays Ext.ActionSheet for confirmation to proceed.
Confirmation on Ext.ActionSheet pushes a subclass of Ext.Carousel onto Ext.NavigationView
From Toolbar of Ext.NavigationView, hitting BACK leaves Carousel and returns to Ext.NavigationView List.
Try to repeat from #1 again, Ext.Prompt asks for password again. However, an error "Uncaught TypeError: Cannot read property 'dom' of null" comes up in console once it reaches #2. ActionSheet does not show. (This error is in Default.js:134).
Within the itemtap handler function in the controller.js file:

Ext.Msg.prompt('Authorization', 'Passcode:',
function(button, value) {
if (correctPassword) {
Ext.Viewport.add(downloadActionSheet);
downloadActionSheet.show();
} else {
Ext.Msg.alert("Access Denied/Cancelled");
}
}, this, false, null
);


ActionSheet instance created in the view.js file:

var downloadActionSheet = Ext.create('Ext.ActionSheet', {
items : [{
text : 'Download',
ui : 'confirm',
id : 'download'
}, {
text : 'Cancel',
ui : 'decline',
handler : function() {
Ext.Viewport.setMasked(false);
Ext.Viewport.remove(downloadActionSheet);
Ext.Msg.alert("Download Cancelled");
}
}]
});


I tried adding a ' renderTo: "Ext.Viewport.element" ' to the downloadActionSheet but that didn't seem to work.

Can someone help me out? What am I missing here? I'm a ST newbie.
Thank you ahead for your patience and help.

evant
7 Mar 2013, 4:30 PM
See the docs for remove, it will destroy the component unless you tell it not to:

http://docs.sencha.com/touch/2-1/#!/api/Ext.Container-method-remove

2b3pro
7 Mar 2013, 8:34 PM
Golly, that was embarrassingly simple. Thank you for your patience.
I was making it more complicated than I needed it to.

I just added a "false"...

Ext.Viewport.remove(downloadActionSheet, false);