-
20 Jun 2012 6:16 AM #1
Unanswered: Passing a Container's custom click event from a view to a controller
Unanswered: Passing a Container's custom click event from a view to a controller
Hi,
I'd like to respond to a tap event on a Container, which doesn't directly support this event, so I'm attaching a tap handler in the Container's initialize and firing a click event which the Controller's ref and control configs should pass to the Controller's event handler. The tap events are detected but they don't seem to get through to the controller. Could you let me know if I'm on the right track?
Thanks,
Haik
Code:// -- View -- Ext.define('MyApp.view.MyComponent', { extend: 'Ext.Container', xtype : 'mycomponent', initialize: function () { this.callParent(arguments); this.element.on({ tap: function() { this.fireEvent('click'); } }); }, ... // -- Controller -- Ext.define('MyApp.controller.MyComponent', { extend: 'Ext.app.Controller', config: { refs: { navItems: 'mycomponent' }, control: { navItems: { click: 'onMyComponentTap' } } }, onMyComponentTap: function(theComponent) { // never gets called }, ...
-
20 Jun 2012 7:04 AM #2
A simple workaround
In the container:
in the Controller:Code:,listeners: { tap: { element: 'element', fn: function() { astri.app.getController('ClassNameController').setVal(this.propert, this.mId); } } }
Otherwise you can do everything in the Controller class:Code:,setVal : function(seg,mid){ //do something }
I hope to help youCode:,'queryOfInterestedView' : { activate: function() { this.setVal(); } }
Bye
-
21 Jun 2012 11:15 AM #3
For a container, there seems to be no clean way to get a tap event without leaving the Sencha object model and dropping down into the HTML DOM. Using a DataView instead of a container solved it as it has tap events (itemTap) while staying on the Sencha level.
-
22 Jun 2012 4:55 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
- Answers
- 3107
You can use a Container and have a tap listener:
Code:new Ext.Container({ fullscreen : true, html : 'Look at the console when you tap', listeners : { element : 'element', tap : function() { console.log('tap'); console.log('scope of listener', this); console.log('arguments', arguments); console.log('----'); } } });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.
-
25 Jun 2012 11:58 AM #5
Thanks. When this event comes in it's an HTMLHtmlElement object, for the div. I went with the itemTap on the DataView instead, as it stays in the Touch world.


Reply With Quote