0
votes

I've extended my utility/class in Sencha Touch 2, now I want to extend it again by different type such that by different settings in config object. Ive extended it again but when it is extended just (by just adding extend: 'Ext.ux.MyUX' again) it returns the previious settings in the previous object, but I want to handle it totally differently. How can I remove the previous extended class or empty that items[].

Ext.define('MyAPP.view.MyView', {
    extend: 'Ext.ux.MyUX',
    xtype: 'my',
});

My Code:

initialize: function() {
var items = [
            xtype: 'toolbar',
            docked: 'top',
            title:'title'
        }];
this.setItems(items);
}

EDIT 1:

Lets say, I've a following config object extending my Ext.ux.MyUX. for the first instance its working perfectly, extending my class and override the items[] but when I want to extend it again, such that for different overriding, it shows the previous items[] that overrided/extended previously.

config: {
        fullscreen: true,
        items : [
        {
            title: 'Home'
        },
        {
            title: 'ABOUT',
            items: [{
                items: [
                { xtype: 'about'},
            {
                xtype: 'titlebar',
                title: 'About Us',
                docked: 'top'
            }]
            }]
        }

        ]
    }
2
Can you post full code of the base and extension classes?Saki
@Saki A simple config of Ext.ux of items can be taken.developer
From the description alone, I have no idea what you want to achieve and what is the problem. So I hope I understand from the code.Saki
@Saki please have a view on edited post. Thanksdeveloper

2 Answers

0
votes

Having items in a class prototype is not a very good idea even if you don't plan to extend the class further. Complex variables from prototype are shared by all instances that inevitably leads to troubles if you have more than one instance.

Be you I'd create a base class that would contain all functionality needed by descendants and I'd extend that:

B -> C
B -> D

instead of

B -> C -> D

Descendants would implement items as needed.

0
votes

There's a really helpful article about how to extend classes with config objects: http://skirtlesden.com/articles/config-objects-on-the-prototype

If this doesn't help I suggest to follow Saki's question for a full source code example. E.g. it's not obvious where you implemented the initialize function and which class you derived from.