1

I am trying to bind a template to my view. But I keep getting template with ID error.

Template: <script type="text/html" id="Template">
//some html markup </script>

View : <div data-bind="template: {name: 'Template'}"></div>

user2904389
  • 43
  • 1
  • 7

1 Answers1

3

It works!

ko.applyBindings({});
<script src="//knockoutjs.com/downloads/knockout-3.3.0.js"></script>
<script type="text/html" id="Template">
  some Markup
</script>

<div data-bind="template: {name: 'Template'}"></div>
Michael Best
  • 16,623
  • 1
  • 37
  • 70
  • I have knockout 3.1.0.min. I tried the same approach but I am getting the same error. Where do we applyBindings ? May be I am not doing it correct. – user2904389 Jul 31 '15 at 13:06
  • You must call it after your document is loaded, so either at the end of ``, or using something like `window.onload`. – Michael Best Jul 31 '15 at 17:23