0

Sencha Touch 2 でコントローラーからビューへの参照を取得したいのですが、この質問の説明に従いました: 自動インスタンス化された Sencha Touch 2 ビューへの参照の取得

それでも、コントローラーの this.control の render および show 関数は呼び出されません。

これは私の app.js です:

Ext.application({

  name: 'App',
  appFolder: 'src',
  controllers: ['Home'],

  launch: function () {
    Ext.Viewport.setActiveItem({xtype: 'homeView'});
  }
});

これは私の見解です:

Ext.define('App.view.HomeView', {

    extend: 'Ext.Panel',
    alias : 'widget.homeView',

    config: {
        html : ['<h1>Sencha Touch Web App</h1>']
    },

    initialize: function() {

        this.callParent();
    }

});

これは私のコントローラーです:

Ext.define('App.controller.Home', {

   extend      : 'Ext.app.Controller',
   views       : ['HomeView'],

init: function() {

   this.control({

       'homeView' : {

           render: function() {
               console.log('Render method called!');
           },
           show: function() {
               console.log('Show method called!');
           }  
        }
    })
  }
});

誰かが私が間違っていることを知っていますか?

どうもありがとう。フランツィスカ

4

1 に答える 1

1

renderハンドラーも呼び出されません。私がそれを行う方法はshow、コンポーネントが表示されるたびに呼び出される use か、ビューが初期化されたときにカスタムイベントを使用することです。

Ext.define('App.view.HomeView', {

    extend: 'Ext.Panel',
    alias : 'widget.homeView',

    config: {
        html : ['<h1>Sencha Touch Web App</h1>']
    },

    initialize: function() {
        this.fireEvent('render');
        this.callParent();
    }

});
于 2011-10-28T10:47:15.337 に答える