Clear all elements of a WinJS Binding List
Posted January 14th, 2013 . 1 Comment .
Sometime you need to updatethe contents of a WinJS binding list with new data, this implies removing current elemens and insert new ones.
I was a little surprised not to have a clear method available, but a quick look at documentation provided a powerful alternative, the splice method.
_items.splice(0, _items.length);
using this simple line all elements will be removed.
The method has a 3rd optional parameter representing the items to insert after elements have been removed, but in my experience it looks like that databinding doesn’t seem to recognize them.