Search code examples
javascriptextjsextjs3

Create ExtJs extend class


I try to extend Button like in sencha example.
I do fiddle
And get error: TypeError: this.addEvents is not a function : 'statesave'.
Whats wrong?


Solution

  • You just forgot to call new and you had a typo see JSFiddle

    PuffButton = Ext.extend(Ext.Button,{
        constructor: function(config){
            PuffButton.superclass.constructor.apply(this,arguments);
            console.log("111111");
            this.on('click',function(){this.el.puff();},this);
        }
    });
    var puff = new PuffButton({text: 'Puff', renderTo:Ext.getBody()});