-
4 Jan 2012 8:53 PM #1
Custom events
Custom events
Hi all,
I'm new to sencha world
,presently started working on Sencha Touch 2. Can someone explain how to register and fire custom events in ST2. I had hard time to run an example,googling the blogs etc.
Thanks in advance
Santosh
-
5 Jan 2012 7:50 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
The important part here is the line in red using fireEvent. To add more arguments to the event, you just add more to the fireEvent:Code:Ext.define('My.Container', { extend : 'Ext.Container', xtype : 'mycontainer', initialize : function() { this.callParent(arguments); this.on('painted', 'checkSomething', this, { single : true }); }, checkSomething : function(cmp) { //do some stuff here this.fireEvent('customevent', this); } }); Ext.create('My.Container', { fullscreen : true, listeners : { customevent : function(cmp) { console.log(arguments); } } });
Code:this.fireEvent('customevent', this, var1, var2);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.
-
5 Jan 2012 8:43 PM #3
thanks mitchell,it worked but...
thanks mitchell,it worked but...
Thanks for your quick reply Mitchell, it worked perfectly. In the above example, "customevent" is fired when container is painted. Here what is "painted"?. how we are able to map "painted" to "customevent" ?
Thanks in advance
Santosh
-
6 Jan 2012 6:40 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
painted in an event bubbled up from the element on the component and fired on the component when it is painted in the DOM. That's not what is important here, the important part is the fireEvent.
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.
-
6 Jan 2012 7:42 AM #5
As your application grows you'll probably want to fire events between controllers which is a little different. Here is how we are doing that:
http://www.sencha.com/forum/showthre...om-controllerA


Reply With Quote