-
18 Dec 2011 1:23 AM #1
Closure
Closure
It would appear to me that there might be a closure problem with calling routines with one of the parameters defined as:
scope: this
There are several routines that use the statement:
var me = this;
And then use 'me' for the scope. That looks like to me to be a proper method to handle closure. Routines like:
Ext.form.Panel, Ext.field.Select, Ext.TitleBar and many others might have a problem.
Try scanning the source code with 'scope: this' or just with ': this' (without the quotes) to review all the situations that might need a closure variable.
Thanks,
Kris
-
18 Dec 2011 5:11 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
Ext.form.Panel, Ext.field.Select, and Ext.TitleBar do not accept scope as a config. Can you be more specific with one example?
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.
-
18 Dec 2011 7:15 AM #3
For Ext.form.Panel starting at line 217:
initialize: function() {
var me = this;
me.callParent();
me.on({
action: 'onFieldAction',
scope : me
});
me.element.on({
submit: 'onSubmit',
scope : this <--------------------------
});
},
For Ext.field.Select starting at line 128:
initialize: function() {
this.callParent();
this.getComponent().on({
scope: this, <-----------------------------------
masktap: 'onMaskTap'
});
},
For Ext.TitleBar.js starting at line 143:
this.sizeMonitors = {
leftBox: new SizeMonitor({
element: leftBox.renderElement,
callback: this.refreshTitlePosition,
scope: this <---------------------------------------
}),
spacer: new SizeMonitor({
element: spacer.renderElement,
callback: this.refreshTitlePosition,
scope: this <-----------------------------------------
}),
rightBox: new SizeMonitor({
element: rightBox.renderElement,
callback: this.refreshTitlePosition,
scope: this <----------------------------------------
})
};
-
18 Dec 2011 7:28 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
The reason for using
Is to save space when compiled, nothing more. In Ext.form.Panel, yeah, that does need to be changed. Ext.field.Select it wouldn't save any space as you have to overcome the characters 'var me = this;' introduces. In Ext.TitleBar, there is a great example of a chance to save a few bytes.Code:var me = this;
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.
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1298
in
2.0.


Reply With Quote