A problem of using "this.",in a button's handler

January 5th, 2009
  • hi,everyone

    i have some problems in customer class now

    this is my code:



    Ext.onReady(function()
    {
    FormWindow = function(config) {
    this.string = "dddd";
    Ext.apply(this, config);
    FormWindow.superclass.constructor.call(this, {
    title: this.title,
    iconCls: 'feed-icon',
    autoHeight: true,
    resizable: false,
    plain:true,
    modal: true,
    autoScroll: true,
    closeAction: 'hide',
    items: this.form,
    buttons:[
    {text:'Button',
    handler:function(){alert(this.string);}
    }
    ]
    });
    };

    Ext.extend(FormWindow, Ext.Window, {
    form : new Ext.Panel({width:400,height:200}),
    title : "Windows"
    });

    win = new FormWindow();
    win.show();

    });









    in the line of the button's handler, i want to alert this.string

    but there's an error said this.string is undefined

    how can i use the this.*** in the handler?:)


  • Because you need to set the scope of the handler.

    http://extjs.com/deploy/dev/docs/?class=Ext.Button&member=scope


  • http://extjs.com/learn/Tutorial:What_is_that_Scope_all_about2#Ext.27s_sco pe_config







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about A problem of using "this.",in a button's handler , Please add it free.

    Posted in dballastages.com | edit