在学习Ext.extend方法时遇到些疑问,请教一下~~
谢谢额!!    Ext.MyWindow = Ext.extend(Ext.Window, {
        width: 300,
        height: 200,
        helloWorld: function () {
            Ext.msg.alert("Hello world!");
        },
        buttons: [
           { text: "调用 helloWorld 方法", handler: function () {               //  这样?
               // Ext.MyWindow.helloWorld() ?
                
            } }
        ]
    });
    Ext.onReady(function () {
        var win = new Ext.MyWindow();
        win.show();    });

解决方案 »

  1.   

    text: "调用 helloWorld 方法", handler:helloWorld
      

  2.   

    麻烦不?
    直接  handler:this.helloWorld, 
      

  3.   

    你们呀,自己都没试过..... 总是想当然的~
            Ext.MyWindow = Ext.extend(Ext.Window, {
                initComponent: function () {
                    var btn1 = new Ext.Button({ text: 'hello', handler: function () { this.helloWorld(); }, scope: this });
                    this.buttons = [btn1];
                    Ext.MyWindow.superclass.initComponent.call(this);
                },
                width: 300,
                height: 200,
                helloWorld: function () {
                    alert("Hello world!");
                }
            });
            Ext.onReady(function () {
                var win = new Ext.MyWindow();
                win.show();        });