Results 1 to 4 of 4

Thread: [2.1][INFO REQ] Form Field onDestroy() called twice

  1. #1

    Default [2.1][INFO REQ] Form Field onDestroy() called twice

    Form Field onDestroy() method is called twice. Here is a test case

    var TestField = function(conf) {, conf);
    Ext.extend(TestField, Ext.form.TextField, {
      onDestroy : function() {"Destroying Test Field ....");;

    new Ext.Window({
               autoHeight: true,
               width: 560,
               items:new Ext.form.FormPanel({items:[new TestField({})]})}).show();
    It breaks our application because we use custom fields (TreePanel) which fails on second onDestroy() call. See

    In addition to fixing double onDestroy() call in form fields you might consider defensive check on childNodes != null in TreeNode destructor


  2. #2
    Sencha User
    Join Date
    Apr 2012
    Austin, Texas


    I don't think this is really a bug. True, in this case, both the base Container and the BasicForm attempt to destroy their items which, for form fields, can be the same items. However, if you look at the code for Ext.destroy(), if you attempt to destroy something that doesn't exist (already destroyed) it will simply skip the logic. If the item is still a valid reference, then attempting to remove listeners and remove the DOM element should not hurt anything. The test case you gave demonstrates that the method is called twice, but it runs fine with no error. Are you sure there's not something in your custom field code that's causing your error?

    TreeNode.childNodes will always exist (it's defined in the base class as this.childNodes = []; ). There is other code in TreeNode that assumes childNodes to be non-null, so I don't think a null check is needed.

  3. #3


    Hi Brian,

    In TreeNOde code destroy() sets childNodes to null so second invocation of destroy() causes error:

    destroy: function () {
        for (var i = 0, l = this.childNodes.length; i < l; i++) {
        this.childNodes = null;
        if (this.ui.destroy) {

  4. #4



    i would like to restart this topic, because i face the same error. I have a basic setup: Window -> FormPanel -> TabPanel -> TreePanel (on first tab). When i close the window, i get an error: this.childNodes has no properties (in ext-all-debug.js line 23122). So this is basically the same issue. I checked it and TreeNode.destroy method is beeing called twice. The first time it's run fine (destroying all nodes), but the second time it's beeing called (on the root node) this.childNodes is null (like roytmana mentioned), so this "for" loop fails.

    Setting this.childNodes to "[]" instead of "null" on line 23125 helped to solve this issue. Are there any plans for this before the next release?


    Update: using 2.1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts