1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    22
    Vote Rating
    0
    premkumarsingh is on a distinguished road

      0  

    Default Unanswered: Uncaught TypeError: Object [object Object] has no method 'getName'

    Unanswered: Uncaught TypeError: Object [object Object] has no method 'getName'


    Uncaught TypeError: Object [object Object] has no method 'getName'

    i am getting this error when i try to run the code below
    can someone please enlighten me on this...

    Code:
    Ext.application({
    	launch: function(){
    var pk=Ext.define('Animal', {
        cofig: {
            name: null
        },
    
    
        constructor: function(cofig) {
            this.initConfig(cofig);
        },
    
    
        speak: function() {
            alert('grunt');
        }
    });
    //var bob = Ext.create('Animal', {
    //    name: 'Bob'
    //});
    
    
    //bob.speak(); //alerts 'grunt'
    Ext.define('Human', {
        extend: 'Animal',
    
    
        speak: function() {
            alert(this.getName());
        }
    });
    
    
    var bob = Ext.create('Human', {
        name: 'Bob'
    });
    
    
    bob.speak(); //alerts 'Bob'
    }
    });
    thanks in advance..
    Last edited by mitchellsimoens; 4 Mar 2012 at 6:28 AM. Reason: added [CODE] tags

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Answers
    3542
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    This

    Code:
    var pk=Ext.define('Animal', {
        cofig: {
            name: null
        },
    
    
        constructor: function(cofig) {
            this.initConfig(cofig);
        },
    
    
        speak: function() {
            alert('grunt');
        }
    });
    should be (cofig should be config):

    Code:
    var pk=Ext.define('Animal', {
        config: {
            name: null
        },
    
    
        constructor: function(config) {
            this.initConfig(config);
        },
    
    
        speak: function() {
            alert('grunt');
        }
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

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

Thread Participants: 1