PDA

View Full Version : How to set a window loader param before the ajax call



mx_starter
19 Jun 2014, 8:57 AM
Hi, i have a simple window, which is loading its contents automatically like this:




Ext.define('app.COMPONENTS.appVideoPlayer', {
extend: 'Ext.window.Window',
,title: 'Video Player'
,modal: true
,closable: true
,resizable: true
,width: 800, height: 600
,autoShow: true
,loader:
{
url: '/video/videocam_loader.html'
,scripts: true
,autoLoad: true
,loadMask: true
,params: { additionalParam: '' }


}

,initComponent: function()
{
var me = this;
me.callParent(arguments);
}
});



Now, i want upon the component creation (and before the loader's ajax call), to add an additional parameter to the loader's params like this:


Ext.create('app.COMPONENTS.appVideoPlayer', { paramToLoader: 'paramValue'});

So - before the ajax call, the params config to contain additionalParam: 'paramValue'

Any suggestions?
In fact, i accomplished this via the beforeload listener within the loader config like this:


listeners: {
beforeload: function(loader, options)
{
options.params.additionalParam = loader.getTarget().paramToLoader;
}
}

But - i'm not sure if this is right approach :(

cmeans
20 Jun 2014, 7:36 AM
Seems like a perfectly reasonable approach (to use the beforeload event).

It's up to your app design as to whether the listener should be in the class declaration verses within an application controller (if you're using the MVC approach).

-Chris