Поделиться через


WinJS.Binding.List constructor

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 WinJS version

WinJS 1.0

Namespace

WinJS.Binding

See also

List