Results 1 to 5 of 5

Thread: the first argument of the click handler is undefined

  1. #1
    Sencha User
    Join Date
    Jul 2010
    Posts
    304

    Default the first argument of the click handler is undefined

    Hi,
    I instanciate a button with a click handler

    Code:
    var newButton = new Ext.Button({
                            id: decomp[i]+i,
                            text: decomp[i],
                            toggleGroup: 'role',
                            listeners: {
                                click: function(button, evt) {
                                    console.log('ca passe');
                                    console.log(button);
                                    currentRole = button.getText().trim();
                                    ............
                               }
                           }
    })
    When I explicitely fire the event "click" I get a javascript error saying that button ( the first argument) is undefined

    What error could it be ?

    Thank you in advance for your answers

  2. #2
    Sencha User
    Join Date
    Aug 2009
    Posts
    480

    Default

    How are you fireing the click event? If you directly call btn.fireEvent('click'); without passing any params, it's normal that no params will get passed to the click handler function.

  3. #3
    Sencha User
    Join Date
    Jul 2010
    Posts
    304

    Default

    Hi scarsick and thank you for your answer,

    you mean that I have to code

    Code:
    btn.fireEvent('click', btn)  ?
    But what about the second argument (the argument evt) for example. It is peculiar that you have to pass arguments

  4. #4
    Sencha User
    Join Date
    Aug 2009
    Posts
    480

    Default

    Yes this is what I mean..., but, why are you trying to manually fire the event? If you want to do something, you can just call a function directly, you don't have to fire the click event so that the function will get called...

  5. #5
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    And if you don't use the event argument, then you don't have to pass it! Doesn't that stand to reason?

Similar Threads

  1. Scope undefined for handler how do I fix it?
    By geewhizbang in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 17 Aug 2009, 1:00 PM
  2. Event handler not being passed options argument
    By ufchrisg in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 15 Dec 2008, 8:34 AM
  3. click event vs handler
    By keckeroo in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 26 Aug 2008, 11:06 AM
  4. click handler doesnt work
    By alexpetri in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 30 Apr 2008, 1:47 AM
  5. Replies: 0
    Last Post: 3 Mar 2008, 1:46 PM

Posting Permissions

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