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