View Full Version : declare ext object inside ajax based panel

11 Sep 2008, 12:34 AM
I'm dynamically loading some panels that contains script to render an Ext button like this..

var b = new Ext.Button({
text: 'Edit',
minWidth: 75,
handler: function(){..},
iconCls: 'Edit'

What happens when the panel is destroyed? I assume this will cause a memory leak. Are there any other alternatives?

(ps. could also use renderTo, but the question remains...)

11 Sep 2008, 12:37 AM
Yes, it will, because you're not registering it with the container.

Check out the RemoteComponent extension, it basically lets you load components via ajax.

11 Sep 2008, 1:03 AM
I'm using my own JsonRender to dynamically create xtype based nested panels (see post in the Extensions), by adding the components to the panel. This results in purgingListeners when the parent is destroyed

but in this case the result from the server is HTML with some additional javascript. Is it enought to just add the button to the items of the parent panel? this.add(btn)

11 Sep 2008, 1:14 AM
Yeah, as long as you register the component with the container, it will get cleaned up when the container is destroyed.

11 Sep 2008, 1:34 AM
next step..
the situation is a grid with a preview panel, clicking on a record in the grid will reload the bottom preview panel using previewPanel.load(url) function.. so it's not destroying the panel, but just set the innerHTML of the body..

next assuming ;) before the load it should do a Ext.destroy(panel.items)... correct?

How can i get a reference to the panel from the javascript that's executed inside the ajax based html result? (without using a hard reference / name)