PDA

View Full Version : XTemplate: if in loop



Holger
24 Jun 2010, 11:30 PM
var tpl = new Ext.XTemplate(
'<div>',
'<tpl for="message">',
'<tpl if="attachment">',
'<div class="ticket-attachment">',
'<tpl for="attachment"><div>{filename}</div></tpl>',
'</div>',
'</tpl>',
'</tpl>',
'</div>'
);


var data = {
message: [
{
/*
attachment: [
{
filename: "myimage.png"
}
],
*/
subject: "..."
},{
subject: "...",
attachment: [
{
filename: "mydoc.doc"
},{
filename: "mypdf.pdf"
}
]
}
]
};
console.log(tpl.apply(data));
I get the following error:

ReferenceError: attachment is not definedWhat's wrong?

Animal
25 Jun 2010, 1:15 AM
'<tpl if="values.attachment">',

Holger
25 Jun 2010, 3:24 AM
That's it, thanks a lot.