Questions tagged [knockout-templating]

Knockout templates are a simple and convenient way to build reusable view pieces, at the same time providing the option of repeating or nested blocks because they can recursively call themselves.

Knockout templates are a simple and convenient way to build reusable view pieces, at the same time providing the option of repeating or nested blocks because they can recursively call themselves.

A template in Knockout is defined using a <script> tag of type="text/html", e.g.:

<script type="text/html" id="person-template">
    <p>
        <span data-bind="text: surname"></span>
        (<span data-bind="text: firstname"></span>)
    </p>
</script>

Optionally, they can be recursive:

<script type="text/html" id="person-template">
    <p>
        <span data-bind="text: surname"></span>
        (<span data-bind="text: firstname"></span>)
    </p>
    <h4>Father:</h4>
    <div data-bind="template: { name: 'person-template', data: father }"></div>
</script>

References

62 questions
0
votes
1 answer

creating a toggle button to change page views

I am using knockout js to get my data to display and i am also using it to bind templates. I have a page that displays the same information in two different ways: one is a grid view and the other is a list view. Currently i have both views displayed…
Masriyah
  • 2,445
  • 11
  • 49
  • 91
-1
votes
1 answer

How to read data on Click binding in Knockout

In foreach i am binding the data as below:
1 2 3 4
5