Question

So I'm trying to follow a tutorial for Knockout, unfortunately the tutorial is using MVC3, and I only have MVC2 with VS2008.

How how can I run something like this:

<script id="tagsTempl" type="text/html">
            <ul>
            {{each tags}}
                <li class="tagItem">
                    <span>${Name}</span>
                    <div>
                        <a href="#" class="tag-edit">Edit</a> <a href="#" class="tag-delete">Delete</a>
                    </div>
                </li>
            {{/each}}
            </ul>
    </script>

in the Webforms ViewEngine? the {{each}} and ${} wont compile unless I'm using Razor. I tried enclosing in a <% %> instead but that didnt work.

Was it helpful?

Solution

What tutorial are you trying to follow? Could you possibly provide a link? From what I'm seeing, it looks as if that template in your code above is a jQuery Template, not MVC or Knockout.

A Knockout template might look something like this:

<script id="tagsTempl" type="text/html">
  <ul>
    <!--ko foreach: $data-->
      <li class="tagItem">
        <span data-bind="text: Name"></span>
        <div>
          <a href="#" class="tag-edit">Edit</a> <a href="#" class="tag-delete">Delete</a>
        </div>
      </li>
    <!-- /ko -->
  </ul>
</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top