推视导航Sencha Touch

时间:2015-01-30 18:14:24

标签: extjs model-view-controller sencha-touch sencha-touch-2

我在Sencha Touch框架中工作,并希望设计一个导航栏以推送我的其他视图。但是,我想添加我的cardlayout(例如:xtype: 'mycard')或小部件(例如:xtype: 'my')。 如何推送已定义为Ext.define('MyProject.view.my', {//some deination})的现有视图。我尝试了以下代码,但在导航栏中按下按钮时无法调用我的handler函数。 我完全无法push任何视图,因为它无法在我的handler函数中运行,也无法调用view.push。 如何将我的视图和推送作为导航项?

尝试使用推送视图的代码:

    //create the navigation view and add it into the Ext.Viewport
    var view = Ext.Viewport.add({
        xtype: 'navigationview',

        //we only give it one item by default, which will be the only item in the 'stack' when it loads
        items: [{
            //items can have titles
            title: 'Navigation View',
            padding: 10,

            //inside this first item we are going to add a button
            items: [{
                xtype: 'button',
                text: 'Push another view!',
                handler: function () {
                    //when someone taps this button, it will push another view into stack
                    view.push({
                        //this one also has a title
                        title: 'Second View',
                        padding: 10,

                        //once again, this view has one button
                        items: [{
                            xtype: 'button',
                            text: 'Pop this view!',
                            handler: function () {
                                //and when you press this button, it will pop the current view (this) out of the stack
                                view.pop();
                            }
                        }]
                    });
                }
            }]
        }]
    });

我的代码:

    {
                        xtype: 'button',
                        text: 'btn',
                        id: 'btn1',
                        scope: this,
                        handler: function(b, e) {
    //here I want to push my view named as xtype: 'my'
// my main viewport has the xtype: 'main' and  alias: 'widget.mypanel'
                        }
                    }

1 个答案:

答案 0 :(得分:0)

尝试即时创建视图,然后将其添加到视图的项目集合中。即在你的事件处理程序中尝试添加

var view = Ext.create('MyProject.view.my', {});
this.add([view]);