2
嗨,我试图从Dave Ward blogjQuery的模板插件
关于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';
}
你可能要阐述什么“错”的意思......你得到一个输出,是输出错的,什么是错的结果,等等等等 – Ben 2010-11-16 01:37:36
@Ben 它没有做任何事情,但戴夫已经回答我的问题,我错过了“行”模板。 – pyccki 2010-11-16 15:58:32