Can Knockout.js bindings apply to container tags AND descendants both?

前端 未结 2 913
日久生厌
日久生厌 2020-12-22 04:53

Let me setup the question with a simple case.

I have an HTML table, the rows of which are controlled by an observableArray. It works great.

If the observable

2条回答
  •  [愿得一人]
    2020-12-22 05:10

    The Knockout-Repeat binding applies the binding to the element itself. It does so by using a node preprocessor to wrap elements with the repeat binding in virtual (comment-based) elements at run time.

    var vm = {
      contacts: ko.observableArray()
    };
    
    ko.applyBindings(vm);
    
    setTimeout(function() {
      vm.contacts(['One', 'Two', 'Three']);
    }, 2500);
    
    
    
    There are no contacts specified yet.

提交回复
热议问题