NibblyPig
NibblyPig

Reputation: 52922

Can I use external markup with knockout JS 2's default template system?

atm I have something like this:

$('#fish').append("<div data-bind='foreach: rows'>" +
  "<div ..." +
  "<p>...</p>"..);

and I don't want nasty inline templates, so I put the template into a <script id='fishtemplate' type='text/html'></script>

I want to append(fishtemplate), is this possible?

Upvotes: 0

Views: 91

Answers (1)

Uladzimir Pasvistselik
Uladzimir Pasvistselik

Reputation: 3921

Try to use:

<div data-bind="template: { name: 'fishtemplate', foreach: row }"></div>

See http://knockoutjs.com/documentation/template-binding.html (section Note 2: Using the “foreach” option with a named template)

Upvotes: 1

Related Questions