PDA

View Full Version : contentEl 'div' destroyed after closing Form



nbize
28 Nov 2007, 3:07 AM
Hi all,

I have a button that fires up a form. The content of that form is located in a hidden div of my main html page, and is loaded with contentEl:

MainPage.html:

<div id="hiddenDiv" style="visibility: hidden">
[content]
</div>

Script:

Ext.get('myBtn').on('click', function(){
var tabs = new Ext.TabPanel({
[...]
items:[{
title: 'Title',
contentEl: 'hiddenDiv'
}]
});
var nav = new Ext.Panel({
[...]
});
var win = new Ext.Window({
[...]
items: [nav, tabs]
});
win.show(this);
}

The first time I click on the myBtn, everything's fine, firebug finds the right node. Once the window is closed, I can't find the hiddenDiv anymore (returns null in Firebug) and I can't open up another similar window.

Any way I can close up the window without destroying my contentEl?

SeaSharp
28 Nov 2007, 3:16 AM
I think this will lead you into the murky world of shallow verses deep element copy logic.

Before discovering Ext I had a similar idea of caching form definitions in hidden DIVs to support fast form rendering. Now with Ext I cache a form's xtype config definition in an Ext collection and then render a new form in the standard Ext way from the cached definition = v.fast.

nbize
28 Nov 2007, 3:28 AM
Thanks for your quick reply! Could you please refer me to an example where that technique is used? I was hidding the DIV because it contained elements on which I had some events handling. Can I obtain the same results with the xtype's config?