Skip to main content
WinJS.Binding.List constructor

Applies to Windows and Windows Phone

Creates a List object.

Syntax


var list = new WinJS.Binding.List(list, options);

Parameters

list

Type: Array

The array containing the elements to initalize the list.

options

Type: Object

You can set two Boolean options: binding and proxy.

If options.binding is true, the list contains the result of calling as on the element values. If options.proxy is true, the list specified as the first parameter is used as the storage for the List. This option should be used with care, because uncoordinated edits to the data storage may result in errors.

Examples

The following code shows how to use the List constructor with the available options.


<div id="result"></div>
    <script type="text/javascript">
        var stringArr = [];
        stringArr.push("abc");
        stringArr.push("abcd");
        stringArr.push("abcde");
        stringArr.push("abcdef");

        var index = stringArr.length;
        while (index-- > 0) {
            stringArr[index] = WinJS.Binding.as(stringArr[index]);
        }

        var stringList = new WinJS.Binding.List(stringArr, {binding: true, proxy: false});

        index = stringArr.length;
        while (index-- > 0) {
            var div = document.getElementById("result");
            div.textContent += stringList.getAt(index);
        }
    </script>

// Output: abcdefabcdeabcdabc

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1

Namespace

WinJS.Binding

Library

Winjs.js

See also

List