1. #1
    Sencha Premium Member
    Join Date
    Nov 2011
    Posts
    27
    Vote Rating
    0
    Answers
    1
    StevenRaines is on a distinguished road

      0  

    Default Answered: Handling "click event" on a Panel

    I am trying to handle a tap / click event on an Ext.Panel. I have found that I can get it to work in the view definition using the following code in the panel definition:

    Code:
    listeners: {
        click: {
        element: 'element',
        fn: function(){console.log('click')}
        }  
    }
    I would like to move this code into a controller, but I can't figure out the proper syntax.

    Any help would be appreciated!




  2. What I usually do is add a listener in the view and fire an event on the component so that it makes it into the controller. Also note that you should use tap instead of click.

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    38,526
    Vote Rating
    1113
    Answers
    3693
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default

    Currently the control config in a Controller doesn't accept event options. You would need to listen in the view and fire an event on the component to be able to listen for tap event on the element.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha Premium Member
    Join Date
    Nov 2011
    Posts
    27
    Vote Rating
    0
    Answers
    1
    StevenRaines is on a distinguished road

      0  

    Default

    What about the "listeners" config instead of control? Is that an option? If not, should the event handler still be in the controller and if so, what is the proper way and define it and call it from the view? For example, is the "click" event I have listened for abstracted or the browser specific click? I need to know what arguments to pass to the function.

    Thanks!

  5. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    38,526
    Vote Rating
    1113
    Answers
    3693
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default

    What I usually do is add a listener in the view and fire an event on the component so that it makes it into the controller. Also note that you should use tap instead of click.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1