0
votes

I'm working in Sencha Touch framework, and want to design a navigation bar to push my additional views. However, I want to add either my cardlayout (eg: xtype: 'mycard' ) or a widget (eg: xtype: 'my'). How can I push my existing view which is already defined as Ext.define('MyProject.view.my', {//some deination}). I tried the following code but unable to call in my handler function when the button pressed in navigation bar. I'm absolutely unable to pushany view as it is not working in my handler function, and unable to call the view.push. How can I get my view and push as a navigation item?

Tried Code for push some view:

    //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();
                            }
                        }]
                    });
                }
            }]
        }]
    });

My Code:

    {
                        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
What means 'push a view' ? Your question doesn't make sense to me.Lorenz Meyer

1 Answers

0
votes

Try to create the view on the fly then add it to the view's items collection. I.e. in your event handler try to add

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