-
6 Mar 2012 9:32 AM #1
Answered: Handling "click event" on a Panel
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:
I would like to move this code into a controller, but I can't figure out the proper syntax.Code:listeners: { click: { element: 'element', fn: function(){console.log('click')} } }
Any help would be appreciated!
-
Best Answer Posted by mitchellsimoens
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.
-
6 Mar 2012 11:09 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
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 Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
9 Mar 2012 6:00 AM #3
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!
-
9 Mar 2012 6:03 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
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 Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote