1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    1
    Vote Rating
    0
    wannes is on a distinguished road

      0  

    Default Unanswered: Cannot call method 'getMargin' of undefined

    Unanswered: Cannot call method 'getMargin' of undefined


    I've looked around and didn't find any solutions yet, so here's my q:
    I got a button and I want it to load a new panel when it's clicked.
    When i click it it says : Cannot call method 'getMargin' of undefined
    So I'm guessing he doesn't know what App.views.viewport is in the controller file

    app.js
    Code:
    Ext.regApplication({    name: 'App',
        defaultUrl: 'Home/index',
        layout: "card",
    
        launch: function()
        {
            this.views.viewport = new App.views.Viewport();
        },
    });
    viewport
    Code:
    App.views.Viewport = Ext.extend(Ext.Panel, {    fullscreen: true,
        layout: 'card',
        cardSwitchAnimation: 'slide',
        dockedItems: [
            {
                xtype: 'toolbar',
                title: 'ChinaTown',
                items: [
                    {xtype: 'spacer'},
                    new Ext.Button({
                        text: 'Bestellingen',
                        itemId:'bestellingOverzicht',
                        listeners: {
                            tap: function(){
                                Ext.dispatch({
                                    controller: 'Home',
                                    action: 'showCart',
                                    displayObject: new App.views.Cart(),
                                    animation: {
                                        type: 'slide',
                                        direction: 'down',
                                        duration: 500
                                    }
                                });
                            }
                        }
                    })
                ],
            },
        ]
    });
    controller
    Code:
    Ext.regController('Home', {
    showCart: function(options){
             
             App.views.viewport.setActiveItem(options.displayObject,options.animation);
        }
    
    });
    
    I feel kinda silly that it won't work, so can anyone push me in the right direction ?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    Answers
    3113
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Two things come to mind right away... I wouldn't use new Ext.Button like you are, you should just be using config objects. What is App.views.Cart?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.