3
* Copyright(c) 2006-2009, Ext JS, LLC.
6
* http://extjs.com/license
9
Ext.namespace('Ext.ux');
12
* @class Ext.ux.ComponentLoader
13
* Provides an easy way to load components dynamically. If you provide these components
14
* with an id you can use Ext.ComponentMgr's onAvailable function to manipulate the components
18
Ext.ux.ComponentLoader = function() {
19
var cm = Ext.ComponentMgr;
26
* Load components from a server resource, config options include anything available in @link Ext.data.Connect#request
27
* Note: Always uses the connection of Ext.Ajax
29
load : function(config) {
31
callback: this.onLoad.createDelegate(this, [config.container], true),
34
if (config.container) {
35
Ext.apply(config.params, {
36
container: config.container
39
Ext.Ajax.request(config);
42
onLoad : function(opts, success, response, ct) {
43
var config = Ext.decode(response.responseText);
45
var comps = config[this.root];
46
// loop over each component returned.
47
for (var i = 0; i < comps.length; i++) {
49
// special case of viewport, no container to add to
50
if (c.xtype && c.xtype === 'viewport') {
54
var ct = c.container || ct;
55
Ext.getCmp(ct).add(c);
56
Ext.getCmp(ct).doLayout();
64
onFailure: function() {
65
Ext.Msg.alert('Load failed.');
b'\\ No newline at end of file'