Эй, ребята, я пробую этот пример из блога Дэйва Уорда
о шаблонах jQuery и о том, что я делаю неправильно.Любая помощь будет оценена.Вот его код: Данные:
var invoice = {
invoiceItems: [
{ type: 'item',
part: '99Designs', description: '99 Designs Logo',
price: 450.00, qty: 1 },
{ type: 'service',
service: 'Web development and testing',
price: 25000.00 },
{ type: 'item',
part: 'LinodeMonthly', description: 'Monthly site hosting',
price: 40.00, qty: 12 }
]
};
Клиент:
<script id="invoiceTemplate" type="x-jquery-tmpl">
<table class="invoice">
{{each lineItems}}
{{tmpl($value) get_invoiceRowTemplateName(type)}}
{{/each}}
</table>
</script>
Js:
$(function ()
{
$('#invoiceTemplate').tmpl(invoice).appendTo('body');
});
function get_invoiceRowTemplateName(type) {
// Return a template selector that matches our
// convention of <type>RowTemplate.
return '#' + type + 'RowTemplate';
}