-
17 Nov 2011 11:26 AM #1
Unanswered: attach a mixin dynamically ?
Unanswered: attach a mixin dynamically ?
Is there a way to attach a mixin to a class after it has been created (or inside its constructor from options)?
-
17 Nov 2011 1:10 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 435
- Answers
- 3106
Yes, you can technically but we recommend that you have it at class creation and then you can execute methods on that mixin later on.
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.
-
17 Nov 2011 2:05 PM #3Sencha - Sencha Touch Dev Team
- Join Date
- Jul 2009
- Location
- Palo Alto, California
- Posts
- 469
- Vote Rating
- 9
- Answers
- 24
You certainly could if absolutely needed using the static 'mixin' method that exists in every class. For example:
Note that this is currently a private API, hence it's still subject to change.Code:Ext.define('A', { foo: true }); Ext.define('B', { bar: true }); A.mixin('b', B);Sencha Touch Lead Architect
-
18 Nov 2011 7:46 AM #4
Hum, seems to fit my needs but i can't make it work :
Code:Ext.define('Ext.i18n.Locale', { extend: 'Ext.Base', mixins: ['Ext.util.Observable'], constructor: function(config) { // Merge defaults this.config = Ext.Object.merge(this.config, config); // Load mixins _.each(this.config.mixins, function(value, key) { Ext.i18n.Locale.mixin(value, Ext.ClassManager.get(value)); });


Reply With Quote