PDA

View Full Version : Problem with data in an xTemplate!?



Mawi
30 Mar 2011, 7:26 AM
hi,

i've a problem with my xTemplate in my Panel.

My data looks like this:



{
id: 1,
name: 'FooCar',
owner: [{
id: 20,
name: 'Bingo'
},{
id: 21,
name: 'John Doe'
}]
}
My template:


Car-ID: {id}<br>
Car Name: {name}<br>
<table>
<tr>
<th>Owner-ID</th>
<th>Name</th>
</tr>
<tpl for="owner">
<tr>
<td>{id}</td>
<td>{name}</td>
</tr>
</tpl>
</table>
but the result is not that, what i expect:


Car-ID: 1
Car Name: FooCar
1 FooCar
so, there are no owners. the only entry i get, is the id and name of the car, but no id's from the owners.

if i change the template to this:


Car-ID: {id}<br>
Car Name: {name}<br>
<tpl for="owner">
{id} - {name}<br>
</tpl>
i get the owners:


Car-ID: 1
Car Name: FooCar

20 - Bingo
21 - John Doe
why my first template doesn't work?

thx

hyteckit
12 May 2011, 2:56 AM
I run into the same issue.

xtemplate doesn't like table, tr, td tags in conjunction with <tpl>