Corrado's Blog 2.0

Online thoughts of a technology funatic

Clear all elements of a WinJS Binding List

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.

1 Comment “Clear all elements of a WinJS Binding List”

  1. if there are more than 100 items, you need to wait long before they are all deleted.

    Comment by Ricardo — 09/01/2014 @ 16:15

RSS feed for comments on this post. TrackBack URL

Leave a Response