May 18, 2012, 10:32 AM
[CLOSED] Switching mode of Loader from Frame to Html and Vice Versa
I've been unable to switch a loader instance between modes without overriding Ext.net.ComponentLoader. Is this the correct way to override it and/or is this already supported functionality?
1. Remove the iframe if it already exists and the mode isn't Frame
2. Use config.renderer instead of this.renderer to register the change in config.
Ext.override(Ext.net.ComponentLoader,
{
load: function (options) {
if (Ext.isString(options)) {
options = { url: options };
}
else {
options = Ext.apply({}, options);
}
if (this.paramsFn) {
this.params = this.paramsFn();
}
if (options.paramsFn) {
options.params = Ext.apply(options.params || {}, options.paramsFn());
}
if (!Ext.isDefined(options.passParentSize) && this.passParentSize) {
options.params = options.params || {};
options.params.width = this.target.body.getWidth(true);
options.params.height = this.target.body.getHeight(true);
}
if (options.renderer == "frame") {
this.loadFrame(options);
return;
}
if (!Ext.isEmpty(this.target.iframe)) {
this.target.removeAll(true);
this.target.iframe = null;
}
if (this.directMethod) {
var me = this,
mask = Ext.isDefined(options.loadMask) ? options.loadMask : me.loadMask,
params = Ext.apply({}, options.params),
callback = options.callback || me.callback,
scope = options.scope || me.scope || me,
method,
dmCfg;
Ext.applyIf(params, me.params);
Ext.apply(params, me.baseParams);
Ext.apply(options, {
scope: me,
params: params,
callback: me.onComplete
});
if (me.fireEvent('beforeload', me, options) === false) {
return;
}
if (mask) {
me.addMask(mask);
}
method = Ext.decode(this.directMethod);
dmCfg = {
complete: function(success, result, response) {
me.onComplete(options, success, { responseText: result });
}
};
if (method.length > 1) {
method(Ext.encode(options.params), dmCfg);
}
else {
method(dmCfg);
}
me.active = {
options: options,
mask: mask,
scope: scope,
callback: callback,
success: options.success || me.success,
failure: options.failure || me.failure,
renderer: options.renderer || me.renderer,
scripts: Ext.isDefined(options.scripts) ? options.scripts : me.scripts
};
me.setOptions(me.active, options);
return;
}
Ext.net.ComponentLoader.superclass.load.apply(this, arguments);
}
});
Changes made are:1. Remove the iframe if it already exists and the mode isn't Frame
2. Use config.renderer instead of this.renderer to register the change in config.
Last edited by Daniil; Jun 15, 2012 at 12:39 PM.
Reason: [CLOSED]