-
24 Oct 2011 11:23 PM #1
Answered: MVC event bubbling - bug or is it just me ?
Answered: MVC event bubbling - bug or is it just me ?
Hi,
I am not sure if this is a bug, or it is just me, so I will post here just in case
Until recently I used ExtJS 4.02a to create an MVC app. I uprated to 4.07, and a strange bug appeared.
In my app there is event bubbling , so that when a field is changed within a form the form is notified. I was controlling this event from the Controller like this:
however,Code:this.control({ 'app_formpanel': { change: function (p){ // do something } } });
after the upgrade this doesn't work,
I have to control the bubble event like this:
Is there any specific reason why in 4.07, handling bubbled events must be done by appending an event handled after render, and not just as regular events (in MVC)?Code:this.control({ 'app_formpanel': { afterrender: function (p){ p.on('change',function (){ // do something }); } } });
Is it just me or is this a bug ? Did somebody else encounter this after using 4.07 ?
p.s. I apologize for posting this twice, but I think here is a better place to ask this question, than the 'Discussions'. The moderators can delete the thread in 'Discussions'. 10x
-
Best Answer Posted by mitchellsimoensWhat this does is gets all 'field's within 'app_formpanel' so since textfield, combobox, etc eventually extend field, this ComponentQuery will listen for the change event on those fields (all subclasses of field).Code:
this.control({ 'app_formpanel field' : { change: someFunction } });
-
25 Oct 2011 2:21 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,710
- Vote Rating
- 436
- Answers
- 3113
Why not just setup a ComponentQuery to listen for the change event? No need to bubble.
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.
-
26 Oct 2011 6:37 AM #3
Hi,
Thanks for the answer. I am not quite sure what you mean by setting up a ComponentQuery to listen.
Could you please give me some hints on this ?
-
26 Oct 2011 6:39 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,710
- Vote Rating
- 436
- Answers
- 3113
What this does is gets all 'field's within 'app_formpanel' so since textfield, combobox, etc eventually extend field, this ComponentQuery will listen for the change event on those fields (all subclasses of field).Code:this.control({ 'app_formpanel field' : { change: someFunction } });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.
-
26 Oct 2011 7:26 AM #5
Ahaa, yep, this is a good idea ! I usually avoid assigning events to multiple components in this manner, because it might result in unwanted behavior.
10x again.


Reply With Quote