1
votes

Is it possible to get a view component in the init function of the controller in sencha touch 2.2.1?

If I am trying the code below, I get undefined for all 3 logs:

refs: {
    mainPanel: '#HomeView'
}
init: function(){
    console.warn(this.getMainPanel());
    console.warn(this.mainPanel);
    console.warn(Ext.ComponentQuery.query('#getOffersButtonHomeView')[0]);
}

Code of the View:

    Ext.define('DeviceAPIFramework.view.HomeView', {
    extend: 'Ext.Panel',
    xtype: 'HomeView',
    id: 'HomeView',
    requires: [
        'Ext.Button',
        'Ext.dataview.List'
    ],

    config: {
        items: [{
            xtype: 'panel',
            layout: 'hbox',
            margin: '5 0 15 15',
            items: [{
                xtype: 'button',
                text: 'Get Offers',
                itemId: 'getOffersButtonHomeView',
                id: 'getOffersButtonHomeView',
                ui: 'confirm',
                width: 150
            }]
        }, {

        .....

Is there any solution for this case?

For the navigation and displaying panels I am using the NavigationView(push method for displaying a view with its xtype), which I added to Ext.ViewPort.

1
Please attach the code of your view. - Darin Kolev
@DarinKolev I added the code of the view. - Niklas

1 Answers

2
votes

I finally figured out that there is a launch function in the controller, which gets called after the view has been initialized.

launch: function() {
    Ext.ComponentQuery.query('#getOffersButtonHomeView')[0].someMethod(someParameter);
},