knockout.js - Update html element with knockout js binding -


I want to update UI with knockout js binding. I am able to update the list, but the changes are not reflected in the UI. I get the following error:

  Unwanted error: You can not apply binding multiple times in the same element.  

The following is my code: When I check the length of the array, the alert show array is up to date, but I want the changes to be visible in the UI.

  & lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Script src = "js / beat-3.0.0 js" & gt; & Lt; / Script & gt; & Lt; Script & gt; Var person = [{Name: "qwe qwe", number: 123123123}, {name: "asd asd", no: 999999999}]; Var myVM = function () {this.persons = ko.observableArray (person); } Function init () {warning (person.length); Ko.applyBindings (new myVM ()); } Function AddPerson () {Pushtoira (person, "name", "123"); in this(); } Function PushToArray (array, var1, var2) {array.push ({name: var1, number: var2}); } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body onload = "init ()" & gt; & Lt; Div & gt; & Lt; Button onclick = "AddPerson ()" & gt; Add & lt; / Button & gt; & Lt; Div data-bind = "foreach: individuals" & gt; & Lt; P data-bound = "text: name" & gt; & Lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

ko.applyBindings () function should only be one Since then, every scene that you do in the viewable object in the view modal will automatically appear in that person.

Simply delete the call in init (); Call the code inside your AddPerson () function and any other place and this should fix the problem


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -