-
24 Feb 2012 8:25 AM #1
Unanswered: How to create custom events and listen to them?
Unanswered: How to create custom events and listen to them?
Hi,
I have a Controller A which has a store S listening to a load event.
When the load event fires I throw a custom event
this.fireEvent('customEvent');
In a Controller B config method I set up a button listening to this event.
The store correctly fires the event but the button doesn't react to it.Code:buttonButton: { 'customEvent': function() { console.log('custom EVENT'); } }
-
24 Feb 2012 8:43 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,085
- Vote Rating
- 453
- Answers
- 3153
Are you using the fireEvent on the button or is the button listening to the event?
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.
-
24 Feb 2012 8:46 AM #3
Currently I fire the event from the store. The button listens to the event by setting it up in a controllers init method.
Code:this.control({ button: { 'myOrdersLoaded': function() { console.log('custom EVENT'); } } });
-
24 Feb 2012 9:01 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,085
- Vote Rating
- 453
- Answers
- 3153
Ok but the button won't know about it. The button needs to directly set a listener onto the store and fire the event on itself
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