PDA

View Full Version : [SOLVED] XTemplate member function on Array



elkidos
4 Dec 2009, 2:48 PM
Hi guys,

XTemplate member functions are working nice for me except in one case: when I want to apply a member function to a simple array.

Ex: I have a simple array named "Notes" (Notes = ['blabla', 'blabla', 'blabla again'])

In the definition of my template, I have this piece of code:


...
'<tpl for="Notes">',
'<li class="list-item">',
'<span class="item-val">{.:this.formatNote}</span>',
'</li>',
'</tpl>',
...
The part {.:this.formatNote} is not working. Do you know how to get it works?

Thanks!!

Condor
5 Dec 2009, 3:45 AM
Are you sure the problem is not in your Notes data?

This test works correctly:

Ext.onReady(function(){
var tpl = new Ext.XTemplate(
'<tpl for=".">{#} {.:this.fn}<br /></tpl>',
{
fn: function(v){
return '&gt;' + v + '&lt;';
}
}
);
tpl.overwrite(Ext.getBody(), ['a', 'b', 'c']);
});

elkidos
5 Dec 2009, 11:13 AM
You're right. The problem was on my side. Thanks Condor! :)