PDA

View Full Version : Convert DOM element to Ext component



sraz786
7 Apr 2010, 3:05 PM
I want to take an existing DOM element, a "DIV" on the page, and wrap this in an Ext component(most likely a Panel). I know I can find the element, get the innerHTML, and set the panel's HTML to this innerHTML, but the I have duplicated the HTML which I don't want to do. Is there a way I can just wrap the DOM element as an ext.component? Thanks!

Animal
7 Apr 2010, 9:15 PM
Are you sure it needs to be a Panel? Does it need header, or footer, or toolbars? Does it need to contain and lay out child Components?

sraz786
7 Apr 2010, 9:54 PM
Actually, I need to take divs from across the page and add them to the items collection of a panel. So, for example:

var a = Ext.get('div1');
var b = Ext.get('div2');

var panel = new Ext.Panel({
...
items:[a,b]
});

When I try to do this, I get an el.dom is null error. The above is essentially what I'm trying to accomplish in concept.

Animal
7 Apr 2010, 11:02 PM
OK, just gathering requirements here.

Those divs, they are just decorative HTML, and they don't need to be or contain Ext Widgets.

This Panel needs to be a Panel does it? It needs header/footer/toolbars etc? Or does it just need to contain these divs?

sraz786
8 Apr 2010, 7:27 AM
Thanks for responding. The divs will contain dynamic content which will be populated via ajax calls. The panel will have a header, footer, and any other panel options I may choose to use. Please let me know if you need more clarification. Thanks again for trying to help!