PDA

View Full Version : this.btnEl is undefined in simple message box



odig
20 Jul 2010, 8:18 AM
Hi,

I am getting the error "this.btnEl is undefined" when clicking OK on a simple message box. I have the following code which first creates a window. Then when they click OK the first time it goes to the tryDeleteAlbum() function which creates the MessageBox with the offending OK button when the selectedIndex == -1:


win = new Ext.Window({
layout: 'fit',
title: 'Delete Album',
modal: true,
items: [combo, deletePhotos],
buttons:[{
text:'OK',
handler: tryDeleteAlbum
},{
text:'Close',
handler: function(){
win.close();
}
}]
});
win.show(this);



function tryDeleteAlbum(){
var forceDelete = false; // Sent to albumhandler.php, will delete album and all photos contained in it if true
var index = combo.selectedIndex;
if( index != -1 ){
var id = store.data.items[index].data.id;
var containsPhotos = photoManager.isAlbumEmpty( id );
//if( containsPhotos &&
var id = store.data.items[index].data.id;
httpRequest( "albumhandler.php?action=deleteAlbum&albumId=" + id, handleAlbumResponse );
win.close();
}else{
// No idea why this doesn't work but it throws an error this.btnEl is undefined when user clicks OK button
Ext.MessageBox.show({
title: 'Select Album',
msg: 'Please select an album to delete from the drop down',
buttons: Ext.MessageBox.OK,,
icon: Ext.MessageBox.WARNING
});
}
}