0

カルーセル付きのアプリがあります。すべてのカルーセル ページには、ボタンや日付ピッカーなどの要素があります。これらの要素のそれぞれで、Sencha Touch を使用して tapStart イベントを処理したいと考えていますが、これを可能にするものを見つけることができませんでした。

誰にもアイデアはありますか?

アップデート

Sencha フォーラムでもこの質問をしました。Sencha フォーラム スレッドへのリンクは次のとおりです

4

2 に答える 2

0

Sencha Touch フォーラムの助けを借りて、問題の解決策を見つけました。

まず、このinitConfig関数を使用してコンテナーの構成を初期化しました。

Ext.define('MyApp.view.ViewName', {
    ...
    // Very Important, this is what I use in the controller to handle the events
    xtype: 'myxtype', 
    ...
    initConfig: function () {
        var me = this;
        this.config = {
            ...
            items: {
                ...
                {
                    xtype: 'button',
                    ...
                    listeners: {
                        element: 'element',

                        // This is where my code handles the tapstart
                        // (touchstart) event
                        touchstart: function () {
                            // Fire an event on the controller (me)
                            me.fireEvent('buttondown');
                        }
                    }
                },
                ...
            }
        }
        this.callParent([this.config]); // Very Important when using initConfig
    }
});

次に、コントローラーに次のコードを追加しました。

Ext.define('MyApp.controller.MainController', {
    ...
    config: {
        views: [
            'ViewName',
            ...
        ],
        ...
    },
    ...
    init: function () {
        this.control({
            'myxtype': {
                buttondown: this.myFunction
            }
        })
    },

    myFunction: function () {
        // Do something
    }
});
于 2013-07-17T13:23:29.113 に答える