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

Knockout JS failed to update observableArray

So I'm trying to add content to an observable array, but it doesn't update. The problem is not the first level content, but the sub array. It's a small comments section. Basically I've this function to declare the comments function comment(id, name,…
Lexx
  • 705
  • 2
  • 9
  • 19
0
votes
1 answer

How can I make my Knockout.js components append to the page without erasing/overwriting any old bindings?

Fiddle: http://jsfiddle.net/mpqtsjhL/27/ Basically I have a Knockout.js component that uses a template: JavaScript: ko.components.register('sublist', { synchronous: true, viewModel: function (params) {}, template: { element:…
0
votes
1 answer

How can I add HTML to this Knockout.js Viewmodel variable?

I have a list of steps displayed on the page. Some steps (but not all) will have 1-3 substeps. I was thinking the simplest way of doing this was to just write the HTML manually within each step declaration in the viewmodel. If you look in the code…
0
votes
0 answers

Knockout External Template Value Reset

Am using Knockout External Template https://github.com/ifandelse/Knockout.js-External-Template-Engine But how to clear newly binded value and text from External template. my html code something like this HTML
0
votes
1 answer

How do I access my viewmodel variables in my knockout component template?

I am trying to create a list of instruction steps using Knockout components/templates. The UL is the going to contain a list of steps (using a knockout-registered custom element sidebar-step) which is just a template of
  • . I have another…
    0
    votes
    1 answer

    How do I get the value of radio button option in my Knockout.js wizard?

    To simplify things, here is the fiddle: http://jsfiddle.net/FyuSD/157/ something like above.. I am…
    0
    votes
    1 answer

    'add' button in the knockout template causes an error

    Trying to include an add button within my knockout template as shown below although I get the following error. If I move the button outside the template and below the form it works strangely.. Any ideas why this is…
    James Radford
    • 1,815
    • 4
    • 25
    • 40
    0
    votes
    1 answer

    How to invoke smth after knockoutjs template will be rendered

    On the page I have only one script, in the head (it is like some advertisement). And in content client have a knockoutjs temlating, and they have filter select. I need to invoke my stuff after select filtering. When user click to filter smth, and…
    0
    votes
    2 answers

    Knockout template stays in loading in some cases

    I used a template in my application like:
    but in some cases, mostly on the first load the output html is lots of Loading... instead of real templates. It…
    mehrandvd
    • 8,806
    • 12
    • 64
    • 111
    0
    votes
    0 answers

    Go to a page/url fragment within a knockoutjs template page

    I have a knockoutjs single page application with a help page template which inside it contains anchors tags/sections with names like "general", "purchases" etc. I am using knockout js templating Help.html

    General

    geeth
    • 21
    • 2