Created
April 8, 2011 20:49
-
-
Save rkmax/910713 to your computer and use it in GitHub Desktop.
Cargador de componententes Extjs via Ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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