PDA

View Full Version : how to destroy a dynamic form?



zjumty
21 Sep 2007, 12:50 AM
hello, all

I create a form dynamically, and I want to delete it after submit.

but, there is no 'destory' or similar function in Ext.form.Form class. and also there is no 'getEl()' function to get the Element of Form.

how can I destory the form?

I find the form element by the following way:

Ext.select("#doc-input-form form").remove();
'doc-input-form' is the id of the html element that the form render to.

I wonder if there is memory leak by this way?

Animal
21 Sep 2007, 1:16 AM
I use this:



Ext.override(Ext.form.BasicForm, {
/** Destroys this form, and all its Fields. */
destroy: function() {
this.destroyed = true;
if (this.txId) {
Ext.Ajax.abort(this.txId);
delete this.txId;
}
this.items.each(function(f){
f.destroy();
});
this.purgeListeners();
this.el.removeAllListeners();
this.el.remove();
Ext.ComponentMgr.unregister(this);
// Ext.form.BasicForm.superclass.prototype.destroy.apply(this, arguments);
}
});

zjumty
21 Sep 2007, 1:30 AM
thank you very much.

I have tried it, it is a good way.

will this be add to ext-2.0 ?

Animal
21 Sep 2007, 1:43 AM
Yes, there is a clearly defined Component heirarchy in Ext 2.0 which all widgets adhere to. The base class implements destroy, and subclasses, as they get more complex, add their own destroy behaviour.

hga77
26 Sep 2007, 2:36 AM
Can we have an example of using that function on a form please? And can we use this for destroying a grid too?

Thanks:D

hga77
29 Sep 2007, 9:36 AM
Even a simple example would do please

Animal
29 Sep 2007, 11:12 PM
Duh, myForm.destroy()?

hga77
30 Sep 2007, 3:06 PM
duh .. ofcourse...:))