PDA

View Full Version : Ext.Loader extra param?



Webtel
24 Nov 2011, 11:37 PM
I need to add extra param to required scripts - decache purpose, but version based (i want to switch version number to have possibility of decacheing production and yet still caching it)

Can anybdy provide Ext.Loader override to have that posiibility. I imagine it to work like:


Ext.Loader.setConfig({
enabled: true,
disableCaching: false,
extraParams:{ _v:1.0 },
paths: { 'TS.lib' : '/library'}
});

tobiu
25 Nov 2011, 1:36 AM
i don't think this is possible yet.

you can take a look at:
http://docs.sencha.com/ext-js/4-0/source/Loader.html

and override the method::


loadScriptFile: function(url, onLoad, onError, scope, synchronous) {
var me = this,
noCacheUrl = url + (this.getConfig('disableCaching') ? ('?' + this.getConfig('disableCachingParam') + '=' + Ext.Date.now()) : ''),
fileName = url.split('/').pop(),
isCrossOriginRestricted = false,
xhr, status, onScriptError;
...

Webtel
25 Nov 2011, 3:32 AM
much thanks, but im facing problem with Ext.Loader override


cls.prototype is undefined
override: function(cls, overrides) {
if (cls.prototype.$className) {


i written something like this.. is it heading right direction? or how it should be done?


Ext.override(Ext.Loader,{

loadScriptFile: function(url, onLoad, onError, scope, synchronous) {
var params = this.getConfig('extraParams');
if(params){
if(!Ext.isString(params))params = Ext.Object.toQueryString(params);
}

var me = this,
noCacheUrl = url + (
this.getConfig('disableCaching') ?
('?' + this.getConfig('disableCachingParam') + '=' + Ext.Date.now()) :
(params ? '?'+params :'')
),
fileName = url.split('/').pop(),
isCrossOriginRestricted = false,
xhr, status, onScriptError;

tobiu
25 Nov 2011, 3:38 AM
Ext.Loader is a singleton (just an JS object), so it can not be overriden like prototype based classes.

you can go for:


Ext.Loader.loadScriptFile = function(){...};


or use Ext.apply() instead.

tobiu
25 Nov 2011, 3:40 AM
feel free to open a feature request fo this topic btw. -> feature request forum.

Webtel
25 Nov 2011, 3:59 AM
great thanks. now it works like a bliss. I will start thread in feature request forum also. Cheers!