PDA

View Full Version : Custom class of renderers



max.carvalho
27 Dec 2010, 8:08 AM
Hi,

I need a class of renderers for my software, I tried something like:


Ext.ns('Visual.renderer');

// date renderer
// date format expected: YYYYMMDD
Visual.renderer = function() {
var trimRe = /^\s+|\s+$/g,
stripTagsRE = /<\/?[^>]+>/gi,
stripScriptsRe = /(?:)((\n|\r|.)*?)(?:<\/script>)/ig,
nl2brRe = /\r?\n/g;

return {

vdate: function(v) {
if (!v || v.length != 8) {
return "";
}
v = new Date(v.substr(0, 4)+', '+v.substr(4, 2)+', '+v.substr(6, 2));
return v.dateFormat("d/m/Y");
}

}
}

but then, I realize that, I have to call the class constructor after the Ext.onReady to have my methods avaliable.
I did something like: Visual.renderer = new Visual.renderer();

I there any other work around, this is right?

Thanks for any help!!!!!!

mschwartz
27 Dec 2010, 8:18 AM
Why do you have to call the class constructor after onReady?

You really want something like:



Visual.renderer = function() {
var trimRe = ....;
return {
...
};
}();


Note the () at the end.

max.carvalho
27 Dec 2010, 8:23 AM
Thaks man!

Works perfect!!!!!