2013-06-20 73 views
3

我嘗試擴展按鈕,如sencha example
我做fiddle
並得到錯誤:TypeError: this.addEvents is not a function : 'statesave'
什麼錯?創建ExtJs擴展類

+0

小提琴的鏈接不起作用 –

+0

對不起。現在修復它。 –

+0

記得調用被覆蓋的方法......'this.callParent(arguments)' – andlrc

回答

4

你忘記打電話給new和你有一個錯字看到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()}); 
+0

OMG我谷歌它約半小時,它只是一個新的!謝謝。 –

+0

@KliverMax不客氣 – sra

1

使用定義來代替。擴展方法已棄用。

Ext.define('Grid', { 
    extend: 'Ext.grid.Panel', 
    constructor: function (config) { 
     this.callParent(arguments); 
    } 
});