1

リストビューをロードすると、左上にいくつかのブログ投稿と更新ボタンがあります。

リストアイテムをタップすると、その特定の投稿の内容が表示されます。このビューを押すと、更新ボタンが非表示になります。

しかし、[戻る]をタップして親リストビューに戻ると、更新ボタンを表示(再表示)したいのですが、非表示のままです。

これを機能させる方法はありますか?

これは私の見解です:

Ext.require(['Ext.data.Store', 'MyApp.model.StreamModel'], function() {
    Ext.define('MyApp.view.HomeView', {
        extend: 'Ext.navigation.View',
        xtype:  'homepanel',

        requires: [
            'Ext.dataview.List',
        ],

        config: {
            title:            'Home',
            iconCls:          'home',
            styleHtmlContent: true,
            navigationBar: {
                items: [
                    {
                        xtype:    'button',
                        iconMask: true,
                        iconCls:  'refresh',
                        align:    'left',
                        action:   'refreshButton',
                        id:       'refreshButtonId'
                    }
                ]
            },
            items: {
                title: 'My',
                xtype: 'list',
                itemTpl: [
                    '<div class="post">',
                        ...
                    '</div>'

                ].join(''),

                store: new Ext.data.Store({
                    model: 'MyApp.model.StreamModel',
                    autoLoad: true,
                    storeId: 'stream'
                }),
            }
        }
    });
});

と私のコントローラー:

Ext.define('MyApp.controller.SingleController', {
    extend: 'Ext.app.Controller',
    config: {
        refs: {
            stream: 'homepanel'
        },
        control: {
            'homepanel list': {
                itemtap: 'showPost'
            }
        }
    },

    showPost: function(list, index, element, record) {

        this.getStream().push({
            xtype: 'panel',
            html: [
                '<div class="post">',
                '</div>'

            ].join(''),
            scrollable: 'vertical',
            styleHtmlContent: true,
        });

        Ext.getCmp('refreshButtonId').hide();
    }
});
4

1 に答える 1

3

これが最善のアプローチであるかどうかはわかりませんが、もし私があなただったら、戻るボタンをタップしたときに発生するナビゲーションビューの戻るイベントを使用します

したがって、関数の横にshowPost、次のようなバック イベント用の別のコントロールを追加する必要があります。

'homepanel list': {
    itemtap: 'showPost'
},
stream: {
    back: 'backButtonHandler'
}

次に、関数を実行しbackButtonHandlerて更新ボタンを再度表示できます。

backButtonHandler: function(button){
     Ext.getCmp('refreshButtonId').show();
}

それが役に立てば幸い :)

于 2012-10-07T05:37:48.927 に答える