artur
7 Jul 2007, 2:11 PM
I mostly code in C++/C# , not a lot in JavaScript so forgive me if I asked some silly questions.
So I use this function to show dialogs on my page. I pass to it DialogId and DialogContent (DialogContent is a valid HTML string).
var Dialog = function(){
return {
Show : function(DialogId, DialogContent){
if(!DialogId) {
var DialogCreated = Ext.get(DialogId);
if(!DialogCreated) {
var dialogTemplate = new Ext.Template('<div id="{name}" style=" display: "none", position: "absolute"></div>');
var dialogBodyRef = dialogTemplate.append(document.body,{name: DialogId}, true);
Ext.DomHelper.append(dialogBodyRef, {
tag: 'div',
id: "dialogheader",
cls: "x-dlg-hd" },
false);
dialog = new Ext.BasicDialog(dialogBodyRef, {
modal: false,
autoTabs:false,
width:500,
height:300,
shadow:false,
minWidth:300,
minHeight:250,
proxyDrag: true });
dialog.addKeyListener(27, dialog.hide, dialog);
}
else {
dialog = (???);
}
dialog.body.update(DialogContent);
dialog.center();
dialog.show();
}
}
};
}();
When I first call this method with DialogId='Dialog1' everyfing works OK - I get a perfect dialog. Next I call this method with DialogId='Dialog2'. Still OK - I get a second dialog.
But now I call this method with DialogId='Dialog1'. Unfortunately dialog2 is updated, not dialog1. This is because a variable 'dialog' holds a reference to dialog2 which was last created.
Question: How can I find a reference to dialog1?
Thank you for your help.
So I use this function to show dialogs on my page. I pass to it DialogId and DialogContent (DialogContent is a valid HTML string).
var Dialog = function(){
return {
Show : function(DialogId, DialogContent){
if(!DialogId) {
var DialogCreated = Ext.get(DialogId);
if(!DialogCreated) {
var dialogTemplate = new Ext.Template('<div id="{name}" style=" display: "none", position: "absolute"></div>');
var dialogBodyRef = dialogTemplate.append(document.body,{name: DialogId}, true);
Ext.DomHelper.append(dialogBodyRef, {
tag: 'div',
id: "dialogheader",
cls: "x-dlg-hd" },
false);
dialog = new Ext.BasicDialog(dialogBodyRef, {
modal: false,
autoTabs:false,
width:500,
height:300,
shadow:false,
minWidth:300,
minHeight:250,
proxyDrag: true });
dialog.addKeyListener(27, dialog.hide, dialog);
}
else {
dialog = (???);
}
dialog.body.update(DialogContent);
dialog.center();
dialog.show();
}
}
};
}();
When I first call this method with DialogId='Dialog1' everyfing works OK - I get a perfect dialog. Next I call this method with DialogId='Dialog2'. Still OK - I get a second dialog.
But now I call this method with DialogId='Dialog1'. Unfortunately dialog2 is updated, not dialog1. This is because a variable 'dialog' holds a reference to dialog2 which was last created.
Question: How can I find a reference to dialog1?
Thank you for your help.