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 回答