atm我有这样的事情:
$('#fish').append("<div data-bind='foreach: rows'>" +
"<div ..." +
"<p>...</p>"..);
我不想要讨厌的内联模板,所以我将模板放入<script id='fishtemplate' type='text/html'></script>
我想append(fishtemplate)
,这可能吗?
答案 0 :(得分:1)
尝试使用:
<div data-bind="template: { name: 'fishtemplate', foreach: row }"></div>
请参阅http://knockoutjs.com/documentation/template-binding.html(注2:将“foreach”选项与命名模板一起使用)