从零开始学习Sencha Touch MVC应用之十八

建立一个新的控制器以处理新闻(NewsController.js):

Ext.regController('News', {
  
    // index action
    index: function(options)
    {
        if ( ! this.indexView)
        {
            this.indexView = this.render({
                xtype: 'NewsIndex',
            });
        }
  
        var backBtn = this.application.viewport.query('#backBtn')[0];
        backBtn.show();
  
        backBtn.setHandler(function()
        {
            Ext.dispatch({
                controller: 'Home',
                action: 'index',
                historyUrl: 'Home/index',
                //
                animation: {
                    type: 'slide',
                    reverse: true,
                },
            });
        });
  
        this.application.viewport.setActiveItem(this.indexView, options.animation);
    },
});


现在新闻控制其索引视图为(NewsIndexView.js):

App.views.NewsIndex = Ext.extend(Ext.List, {
    store: 'NewsItems',
    itemTpl: '{title}, <span class="date">{date}</date>',
});
Ext.reg('NewsIndex', App.views.NewsIndex);


正像我们前面所见,我们已经采用了 Ext.List 组件来显示新闻.
posted @ 2012-05-08 14:57  范永强  阅读(110)  评论(0编辑  收藏  举报