Results 1 to 4 of 4

Thread: [4.07] State isn't destroyd when object is destroyd

    Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.
  1. #1

    Default [4.07] State isn't destroyd when object is destroyd

    I have a panel with VBox layout.

    I add 2 new panels to its items collection with id's 'child1' and 'child2', both with flex set to 150
    I remove both items (using autoDestroy true)

    I add 3 items with id's 'child1', 'child2' and 'child3', all with flex set to 100

    The first two items get flex 150, the third one gets flex 100.

    This happens because during component creation, the state is looked up in the Ext.state.manager by id and apparently the states of 'child1' and 'child2' weren't deleted upon destroy of the components...

  2. #2
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    @Caius --

    Please post your Panel config/class definition for review.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  3. #3

    Default The code

    In the code below, everytime you click the Add Item button in the left panel, all buttons are removed from the center panel and new buttons are added (one more than existed previously). They all get the same flex value, but they don't become the same size. Debugging shows that for button's with an id that existed before, the flex value is retrieved from the state with that id. I presumed that the state would be destroyed with the button upon removal...


    Code:
    Ext.application({    name: 'JSTest',     launch: function () {        Ext.create('Ext.container.Viewport', {            layout: 'border',            items: [                {                    xtype: 'panel',                    region: 'north',                    html: '<h1>JavaScript Test</h1>'                },                {                    xtype: 'panel',                    region: 'west',                    title: 'Left Panel',                    layout: 'absolute',                    split: true,                    width: 300,                    items: [                        {                            xtype: 'button',                            x: 10,                            y: 10,                            text: 'Add item',                            handler: function () {                                var p = Ext.getCmp('p');                                var n = p.items.length + 1;                                p.removeAll(true);                                for (var i = 1; i <= n; i++) {                                    p.add(Ext.create('Ext.button.Button', {                                        xtype: 'panel',                                        border: true,                                        flex: 1000 / n,                                        id: 'p' + i.toString(),                                        text: 'p' + i.toString()                                    }));                                }                            }                        },                         {                             xtype: 'button',                             x: 10,                             y: 50,                             text: 'Clear',                             handler: function () {                                 var p = Ext.getCmp('p');                                 p.removeAll(true);                             }                         }                    ]                 },                {                    id: 'p',                    xtype: 'panel',                    region: 'center',                    title: 'Center Panel',                    layout: { type: 'vbox', align: 'stretch' }                }            ]        });    }});

  4. #4

    Default Code, again

    Sorry, the code missed its linebreaks, this one is better

    Code:
    Ext.application({
        name: 'JSTest',
    
    
        launch: function () {
            Ext.create('Ext.container.Viewport', {
                layout: 'border',
                items: [
                    {
                        xtype: 'panel',
                        region: 'north',
                        html: '<h1>JavaScript Test</h1>'
                    },
                    {
                        xtype: 'panel',
                        region: 'west',
                        title: 'Left Panel',
                        layout: 'absolute',
                        split: true,
                        width: 300,
                        items: [
                            {
                                xtype: 'button',
                                x: 10,
                                y: 10,
                                text: 'Add item',
                                handler: function () {
                                    var p = Ext.getCmp('p');
                                    var n = p.items.length + 1;
                                    p.removeAll(true);
                                    for (var i = 1; i <= n; i++) {
                                        p.add(Ext.create('Ext.button.Button', {
                                            xtype: 'panel',
                                            border: true,
                                            flex: 1000 / n,
                                            id: 'p' + i.toString(),
                                            text: 'p' + i.toString()
                                        }));
                                    }
                                }
                            },
                             {
                                 xtype: 'button',
                                 x: 10,
                                 y: 50,
                                 text: 'Clear',
                                 handler: function () {
                                     var p = Ext.getCmp('p');
                                     p.removeAll(true);
                                 }
                             }
                        ]
    
    
                    },
                    {
                        id: 'p',
                        xtype: 'panel',
                        region: 'center',
                        title: 'Center Panel',
                        layout: { type: 'vbox', align: 'stretch' }
                    }
                ]
            });
        }
    });

Tags for this Thread

Posting Permissions

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