1. #1
    Sencha User cyberwombat's Avatar
    Join Date
    Oct 2011
    Posts
    237
    Answers
    6
    Vote Rating
    2
    cyberwombat is on a distinguished road

      0  

    Default Answered: Change cards from a button

    Answered: Change cards from a button


    I have a simple card layout and can't figure out the syntax in my onButton handler to switch active items. Funny is that I can do it in a larger mvc context just not in this simple app I need to file a bug

    Code:
    Ext.application({
        name: 'Sencha',
        main: null,
        refs: [
        {
            ref: "panel",
            selector: "mypanel"
        }
        ],
        init: function() {
            this.control({
                '#switch': {
                    tap: this.onButton
                },
            })
        },
        launch: function() {
            this.main = Ext.create("Ext.Panel", {
                fullscreen: true,
                layout: 'card',
                xtype: 'mypanel',
                items: [
                    {
                    title: 'Home',
                    iconCls: 'home',
                    cls: 'home',
                    html: 'home page',
                },
                {
                    title: 'Contact',
                    iconCls: 'user',
                    xtype: 'formpanel',
                    url: 'contact.php',
                    layout: 'vbox',
                    items: [
                       {
                        xtype: 'fieldset',
                        title: 'Contact Us',
                        instructions: '(email address is optional)',
                        items: [
                            {
                                xtype: 'textfield',
                                label: 'Name'
                            },
                            {
                                xtype: 'emailfield',
                                label: 'Email'
                            },
                            {
                                xtype: 'textareafield',
                                label: 'Message'
                            }
                        ]
                    },
                    {
                        xtype: 'button',
                        itemId: 'switch',
                        id: 'switch',
                        text: 'Send',
                        ui: 'confirm',
                    }
                    ]
                }
                ]
            });
    
    
            this.main.setActiveItem(1);
        },
        onButton: function() {
            this.getPanel().setActiveItem(0);  //doesn't work
                //? how do I switch from here
        }
    });

  2. This looks like a bug with control(). The scope it is getting is null, so this == Window.

    To get around it for now, you can pass in a 3rd argument into control() which is the scope (this).

    Code:
    this.control({
        '#switch': {
            tap: this.onButton
        }
    }, null, this);

  3. #2
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Answers
    93
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    You can't add refs to an application directly, they must be in a Ext.app.Controller subclass. I think this is coming in for 2.0, but don't hold me to that.

    So, in this example, you'd have to store a reference to the panel you want to switch cards, and make sure you are in the correct scope, and call setActiveItem. Or use Ext.ComponentQuery.query to find your panel, and do it that way.

    Also, you cannot set an `xtype` when creating a Component like you did with 'my panel'. You can only do that when extending a class.
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  4. #3
    Sencha User cyberwombat's Avatar
    Join Date
    Oct 2011
    Posts
    237
    Answers
    6
    Vote Rating
    2
    cyberwombat is on a distinguished road

      0  

    Default


    I would have thought that this.main = ... was a good reference and that I could use this.main.setActiveItem but that doesn't work. Not sure how to change the scope from the onButton method. Tried var a= this, etc but no go. I assumed it was a scope thing but I don't see in my example why main cannot be accessed. The scope thing in Sencha confuses the heck out of me

  5. #4
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Answers
    93
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    This looks like a bug with control(). The scope it is getting is null, so this == Window.

    To get around it for now, you can pass in a 3rd argument into control() which is the scope (this).

    Code:
    this.control({
        '#switch': {
            tap: this.onButton
        }
    }, null, this);
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  6. #5
    Sencha User cyberwombat's Avatar
    Join Date
    Oct 2011
    Posts
    237
    Answers
    6
    Vote Rating
    2
    cyberwombat is on a distinguished road

      0  

    Default


    Oh good god.. no wonder - been trying to get this right at this for weeks

  7. #6
    Sencha User
    Join Date
    May 2009
    Posts
    32
    Vote Rating
    0
    casic has a little shameless behaviour in the past

      0  

    Default Chnging view in Kitchenskink.

    Chnging view in Kitchenskink.


    Hi , i 'm using kitchensink like base for my project. I know how to change views that are included in /store/Demo.js / like items by ID . But if i create new view , and want to change to it by name , how would look the showViewByName function ????? I 'm trying without success .
    Can you help me ??

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar