WinJS.Binding.List constructor

0 out of 4 rated this helpful - Rate this topic

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

Namespace

WinJS.Binding

Library

Base.js

See also

List

 

 

Build date: 12/5/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.