I have an observable knockout array populated with some initial values โโwhen the web page loads, and I want to add to the observable array using the splicing method when the user interacts with the page. The new elements that I am trying to add to the array have the same properties as the original elements in the array, but when I try to merge the new elements into an existing array, I get a knockout binding error, for example: " Error: Unable to parse bindings. Message : ReferenceError: ContactName not defined; Binding value: text: ContactName ". This error occurs even if the property in question exists in all elements of the new array. I am trying to splicing in a Knockout observable array, not the main array object, because I want the bindings to be updated automatically. The splicing code is as follows: vmContacts.Contacts.splice(vmContacts.Contacts().length,0,contactData2); .
I created an example of a violin here so you can see it in action: http://jsfiddle.net/ak47/pMFwe/ . You will see an error in the browser console when you click the "Add Contacts" button.
I would like to avoid a loop through an array of new objects, to do push () for each element that I need to add, where the splice should work, but it is not. Is this a known knockout problem, or am I doing something wrong? Thanks for the help!
source share