1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    38
    Vote Rating
    1
    howHardCanItBe is on a distinguished road

      0  

    Default Answered: attempts to view created class cause "Object [object Object] has no method 'getId'"

    Answered: attempts to view created class cause "Object [object Object] has no method 'getId'"


    When I make a class a xtype I am having no problem adding it to a viewport or working with the object. When I create a class instance and attempt to add it to viewport or to my main container I get the "no method 'getId'" error. As you can see below I don't have a configuration object called Id so I am a bit lost as to what the problem is. What am I missing?

    The class:

    Code:
    Ext.define('ArticlePage', {
        extends: 'Ext.Panel',
        id: 'Article_Page',
        layout: 'stretch',
        items: [
            {
                xtype: 'toolbar',
                docked: 'top',
                items: [
                    {
                        xtype: 'button',
                        text: 'Back',
                        handler: function () {
                            console.log('test');
                        }
                    },
                    {
                        xtype: 'button',
                        text: 'Previous'
                    },
                    {
                        xtype: 'button',
                        text: 'Next'
                    },
                    {
                        xtype: 'spacer'
                    },
                    {
                        xtype: 'button',
                        text: 'Add to my folder'
                    }
                    //TODO body
                ]
            }
        ]
    });
    The function I am trying to create/show it in:

    Code:
            this.element.on({
                click: function (e, t) {
                    var article = Ext.create('ArticlePage');
                                    
                    // app is a panel that is card, ideally the class would be shown here
                    //Ext.getCmp('app').add(article); 
                    //Ext.getCmp('app').setActiveItem('Article_Page', { type: 'slide', direction: 'left' });
    
    
                    // same error trying to add to viewport
                    Ext.Viewport.add(article);
                }
            });

  2. You have a few issues:

    - extend is the extend keyword, not extends
    - you must define all configurations inside the config block when defining a class. Something like this:

    Code:
    Ext.define('ArticlePage', {
        extend: 'Ext.Panel',
        config: {
            id: 'ArticlePage',
            html: 'one'
        }
    });

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

      0  

    Default


    You have a few issues:

    - extend is the extend keyword, not extends
    - you must define all configurations inside the config block when defining a class. Something like this:

    Code:
    Ext.define('ArticlePage', {
        extend: 'Ext.Panel',
        config: {
            id: 'ArticlePage',
            html: 'one'
        }
    });
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  4. #3
    Sencha User
    Join Date
    Sep 2011
    Posts
    38
    Vote Rating
    1
    howHardCanItBe is on a distinguished road

      0  

    Default


    Thanks for the ninja fast response. When it comes to adding things to the config is there any option for not creating the get/set/apply?

Thread Participants: 1