I don't understand the usage of alias vs id vs itemId config properties in ExtJS
app/view/foo.js
Ext.define('app.view.foo', {
...
alias: 'widget.foo', // 1
id: 'foo', // or 2
...
});
app/controller/goo.js
Ext.define('app.controller.goo', {
...
views: ['foo', ...],
init: function() {
this.control({
'foo': {...}, // 1
'#foo': {...} // or 2
...
});
...
},
...
});
With alias I can use xtype easily.. but what advantage do I gain by setting id's to my views?
An alias is set on the class definition, using Ext.define, and is what is used for the xtype when creating instances (you seem to have the hang of this). An id should be set on a class instance, e.g. when using Ext.create. This just serves as a unique identifier for a particular instance of a component.
FWIW, id should be used sparingly. You are much better served using itemId and referencing components relatively using that, rather than globally with an id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With