2

私は最初の小さな Sencha Touch 2 アプリを構築しようとしています。期待どおりに機能するものをいくつか作成しましたが、イベント処理のものを作成したいと思います。

次のストアを作成しました。

Ext.define('Mobile.store.Blogs', {
    extend: 'Ext.data.Store',

    config: {
    },
    listeners: {
        'load' :  function(store,records,options) {
            store.loaded = true;
            console.log("fired blogCountAvailable");
            store.fireEvent("blogCountAvailable");
        },
        'blogCountAvailable': function(store, records, options) {
            console.log("blogCountAvailable has been fired");
        }
    }
});

これは期待どおりに機能しますが、次のステップに進みます。

これが私のタブパネルバーのコードです:

    Ext.create("Ext.tab.Panel", {
        xtype:'mainTabPanelBottom',
        tabBarPosition: 'bottom',
        fullscreen: true,
    items: [
            {
                title: 'Blog',
                iconCls: 'home',
                xtype:'mainpanel'
            },
            {
                title: 'Users',
                iconCls: 'user',
                xtype:'userpanel'
            }
    ],
        listeners: {
            blogCountAvailable: function(tabpanel, newTab) {
                var tab   = newTab.tab,
                            badge = 10;

                tab.setBadge(badge);

                console.log("blogCountAvailable has been fired");
            }
        }
    });

私の質問は、カスタム イベントblogCountAvailableをタブ パネルに「起動」する方法を教えてください。

4

1 に答える 1

1

最も簡単な方法は、TabPanelのIDを設定してから、次のことを行うことです。

Ext.getCmp('your_TabPanel_id').fireEvent("blogCountAvailable");
于 2012-04-26T14:44:52.300 に答える