Creating an Observable Collection of Observables

By default, when you create a WinJS.Binding.List from a JavaScript array, the list is observable but not the items in the list. The WinJS.Binding.List simply contains the items from the array and the items are plain old JavaScript objects.

If you want to convert each of the items from the JavaScript array into an observable item, then you need to use the binding option when creating the WinJS.Binding.List like this:

var products = [    { name: "Milk", price: 2.99 },    { name: "Oranges", price: 2.50 },    { name: "Apples", price: 1.99 }];// Create Listvar productsList = new WinJS.Binding.List(products, { binding: true });// Listen for changes in priceproductsList.getAt(1).bind( ...

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.