Ext.MyWindow = Ext.extend(Ext.Window, { width: 300 , height: 200 , addButtons: function () { if (!this.buttons) { this.buttons = []; } Ext.each(arguments, function (arg) { this.buttons.push(arg); }, this) } , initTools: function () { Ext.MyWindow.superclass.initTools.call(this); console.log("initTools"); this.addButtons([{ text: "提交", handler: this.submit.createDelegate(this) },
{ text: "关闭", handler: this.hide.createDelegate(this)}]) } , hide: function () { Ext.MyWindow.superclass.hide.call(this); } , submit: function () { Ext.Msg.alert("X"); } }); Ext.onReady(function () { var win = new Ext.MyWindow(); win.show(); });