1. #1
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    58
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default [2.1][FIXED] Container does not destroy its layout when it is destroyed.

    [2.1][FIXED] Container does not destroy its layout when it is destroyed.


    Most of the time, this does not make a difference. But some layout managers set up structures and listeners which must be destroyed.

    A hook should be built into ContainerLayout: destroy: Ext.emptyFn,

    And the more complex layouts should implement this if they need to clean up after themselves.

    For example, border layouts leave splitter elements scattered around the DOM.

    I use the following 3 overrides.

    Implement an onDestroy for Ext.Container (It doesn't have an implementation yet):

    Code:
    Ext.override(Ext.Container, {
        onDestroy: function() {
    //      If we have a layout, and it is a correctly instantiated layout manager
    //      with a destroy function, destroy it.
            if (this.layout && typeof this.layout.destroy == 'function') {
                this.layout.destroy();
            }
            Ext.Container.superclass.onDestroy.apply(this, arguments);
        }
    });
    Implement a destroy method in the Layout base class:

    Code:
    // Define null implementation of destroy in the base class
    Ext.override(Ext.layout.ContainerLayout, {
        destroy: Ext.emptyFn
    });
    For now, BorderLayout is the only layout which needs to clear up after itself:

    Code:
    Ext.override(Ext.layout.BorderLayout, {
        destroy: function() {
            var r = ['north', 'south', 'east', 'west'];
            for (var i = 0; i < r.length; i++) {
                var region = this[r[i]];
                if (region && region.split) {
                    region.split.destroy(true);
                }
            }
        }
    });

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    Nice suggestion. A slightly modified version will be in SVN shortly.
    Jack Slocum
    Ext JS Founder
    Original author of Ext JS 1, 2 & 3.
    Twitter: @jackslocum
    jack@extjs.com

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Posts
    34
    Vote Rating
    0
    grEvenX is on a distinguished road

      0  

    Default


    Is this fixes implemented in 2.2?

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    58
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Yes.

Thread Participants: 2