Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sencha xtype navigation fails when adding initialize function

I have a Home.js view with some embedded xtype's for subpages in a bottom bar. First I added the other Views in the config and all was fine, but now I need to set some other stuff (i.e. username) using the initalize method.

But, now the navigation to the other views doesn't fire anymore. Nothing happens, no action is fired or any error. The view is still shown correctly.

The View

Ext.define('MyApp.view.Home', {
extend : 'Ext.tab.Panel',
id : 'home',
xtype : 'homeview',
requires : ['Ext.TitleBar', 'Ext.Video', 'MyApp.view.Profile'],

initialize : function() {

    console.log('Initializing Home');
    var me = this
    var config = me.getInitialConfig();
    var username = config.username;
    var items = [];

    items.push({
        xtype : 'titlebar',
        docked : 'top',
        title : 'Hello ' + username
    }, {
        xtype : 'updatesview',
    }, {
        xtype : 'searchview',
    }, {
        xtype : 'profileview'
    }, {
        xtype : 'messagesview'
    }, {
        xtype : 'sensesview'
    });

    me.setItems(items);

    console.log('Initializing Home');
},
config : {
    title : 'Home',
    iconCls : 'home',
    tabBarPosition : 'bottom'

}

});

Switching back to this works (????)

The old view, using only config

Ext.define('MyApp.view.Home', {
extend : 'Ext.tab.Panel',
id : 'home',
xtype : 'homeview',
requires : ['Ext.TitleBar', 'Ext.Video', 'MyApp.view.Profile'],

config : {
    title : 'Home',
    iconCls : 'home',
    tabBarPosition : 'bottom',
    items : [{
        xtype : 'updatesview',
    }, {
        xtype : 'searchview',
    }, {
        xtype : 'profileview'
    }, {
        xtype : 'messagesview'
    }, {
        xtype : 'sensesview'
    }]
}

});

Update

I tried both

me.setItems(items);
me.addItems(items);

None work.

Update 2

OK the problem lies with the initialize function. ANY init disables the navigation (??)

initialize : function() {
    console.log('init home');
},

Thanks for your help!

like image 233
Coen Damen Avatar asked Aug 23 '26 14:08

Coen Damen


1 Answers

I think you need to call the parent init method in your init:

...
initialize : function() {
  this.callParent(arguments);
  ...
  // Rest of your code...
},
...
like image 86
Jordan Kasper Avatar answered Aug 26 '26 04:08

Jordan Kasper