PDA

View Full Version : XTemplate tpl - browser complains "if" value 'is undefined'



Shibani
17 Mar 2011, 7:39 AM
I'm using an XTemplate and appending tpl data. When I use an if statement, the browser complains that 'sport' is undefined. If I remove the if, the html <td>{sport}</td> returns the correct value

Example:

var tplData = [{
sport : "Baseball"
}];

var tpl = new Ext.XTemplate(
'<table>',
'<tr>',
'<td>{sport}</td>', // shows the correct value when I exclude the following tpl lines
'<tpl if="sport == &quot;Baseball&quot;">',
'<td>Red Sox</td>',
'</tpl>',
'</tr></table>'
)

tpl.compile();
tpl.append(document.body, tplData);

Shibani
17 Mar 2011, 12:30 PM
Sorry, I put this in the wrong forum by mistake.