PDA

View Full Version : destroy is not working for BasicDialog in IE



ethraza
21 Jun 2007, 3:29 PM
Imagem a function that creates my dialogs:

function createbox(...) {
var bdlg = new Ext.LayoutDialog(Ext.id(), {
autoScroll: true,
width: iWidth,
height: iHeight,
minWidth: 150,
minHeight: 100,
modal: bModal,
proxyDrag: true,
shadow: true,
center:{
alwaysShowTabs: false,
fitContainer: true,
fitToFrame: true,
autoScroll: true
}
});
bdlg.addButton(p[0], eval(p[1]), bdlg);
bdlg.body.load({url: sContent, scripts:true, params:sParams})
bdlg.header.update(sTitle)
bdlg.addKeyListener(9, function(i,k,e){e.stopEvent()}, bdlg); // Trying to stop TAB to keep modal
bdlg.addKeyListener(27, function(){bdlg.destroy(true)}, bdlg); // ESC to close
bdlg.show();
return bdlg;
} Now, on scripts I call that function and the returned object go to a variable:
<script>
var bx = createbox(...);
bx.destroy();
</script>
When I call destroy() or hide(), with basicdialog or layoutdialog, it works and close the dialog on FF2 but not works on IE6 or 7.
Why? Is a bug or my mystake?

Thanks!

*** Edited to get the addKeyListener for TAB working!

ethraza
26 Jun 2007, 11:12 AM
For anyone that may pass through it one day, I resolved like this:

<script>
window.bx = createbox(...);
window.bx.destroy(true);
</script>

What I did is to define the bx variable in the window global scope on creation time, so it can be accessed from anywhere on IE.
On firefox it is not necessary but works too, so if u want cross browser, you need to use the window scope.

ValterBorges
30 Sep 2007, 5:50 PM
Using IE 6 with v 1.1

I was having a problem where the setTitle would not replace the title on an existing dialog

To solve the problem I had to destroy the object and have to set the boolean parameter to true otherwise the window title remained the same.

In the object constructor I set

var self = this;
self.lDialog = null;


In success dialog method I have the following:

if (self.lDialog)
{
self.lDialog.destroy(true);
}

self.lDialog = new Ext.LayoutDialog("msg",{autoCreate:true,autoScroll:true,height:575, width:775, modal:true,proxyDrag:true,shim:true});

self.lDialog.setTitle("Success");
self.lDialog.body.update('<div id="Dialog" style="border:1px solid #99bbe8;overflow: scroll; width: 100%; height: 100%; background-color:#FFFFFF">Success Message</div>');

In the failure dialog I have:

if (self.lDialog)
{
self.lDialog.destroy(true);
}

self.lDialog = new Ext.LayoutDialog("msg",{autoCreate:true,autoScroll:true,height:575, width:775, modal:true,proxyDrag:true,shim:true});

self.lDialog.setTitle("Failure");
self.lDialog.body.update('<div id="Dialog" style="border:1px solid #99bbe8;overflow: scroll; width: 100%; height: 100%; background-color:#FFFFFF">FailureMessage</div>');