Skip to content

Instantly share code, notes, and snippets.

@rkmax
Created April 8, 2011 20:49
Show Gist options
  • Save rkmax/910713 to your computer and use it in GitHub Desktop.
Save rkmax/910713 to your computer and use it in GitHub Desktop.
Cargador de componententes Extjs via Ajax
Ext.namespace('Ext.ux');
/**
* @class Ext.ux.ComponentLoader
* @author Aaron Conran
* Provides an easy way to load components dynamically. If you name these components
* you can use Ext.ComponentMgr's onAvailable function to manipulate the components
* as they are added.
* @singleton
*/
Ext.ux.ComponentLoader = function () {
var defaultXType = 'panel';
var cm = Ext.ComponentMgr;
return {
/**
* Load components from a server resource, config options include anything available in @link Ext.data.Connect#request
* Note: Always uses the connection of Ext.Ajax
*/
load: function (config) {
Ext.apply(config, {
callback: this.onLoad,
scope: this
});
Ext.Ajax.request(config);
},
// private
onLoad: function (opts, success, response) {
var config = Ext.decode(response.responseText);
for (var i = 0; i < config.components.length; i++) {
var comp = cm.create(config.components[i], config.defaultXType[i] || defaultXType)
}
}
};
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment