Results 1 to 1 of 1

Thread: Question re:Ext.Panel.addButton() parameter list

  1. #1
    Sencha User
    Join Date
    Jan 2009
    Ottawa, ON, Canada

    Thumbs up Question re:Ext.Panel.addButton() parameter list

    The examples I've found for Ext.Panel's addButton method only pass the first parameter (the button object or definition for a button). When I try to use the other two parameters to set the handler and the scope, I can't get it to work.

    Within the code defining the main panel I have:
    var btnOk = new Ext.Button({
        text: OpenLayers.i18n("Bookmarks.Ok.Button")
     this.addButton(btnOk, myOnClickOk, this);
    And I have a definition for myOnClickOk, but it never gets called:
    myOnClickOk: function(){
    At runtime, it gets to the point in the Ext.Button's onClick method where it checks for the existence of a handler and, using a debugger, I find there isn't one associated with the button.

    During initialization of the panel, within the Ext.Panel addButton method, it seems to try to set this information with the passed parameters but then they get lost when the new Button is created by the method. The new button (that is actually added to the panel) has no handler associated to it.

    Now, similar to the examples I've found, I can get it to work if I define it as follows:
    var btnOk = new Ext.Button({
        text: OpenLayers.i18n("Bookmarks.Ok.Button")
        ,handler: myOnClickOk
        ,scope: this
    but I'm wondering if anyone's ever gotten it to work the other way and I'm just missing something or if there is actually a different problem that needs to be addressed.

    I should note that I am currently using ExtJs 2.2 and this may have been addressed in a later version. At the moment, I am not able to upgrade to check.

    Last edited by myExtJsUname; 15 Jul 2009 at 8:22 AM. Reason: Indicated version of ExtJs using

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts