WinJS.Utilities.data function

Applies to Windows and Windows Phone

Gets the data value associated with the specified element.

Syntax


var object = WinJS.Utilities.data(element);

Parameters

element

Type: DOMElement

The element.

Return value

Type: Object

The value associated with the element.

Examples

The following code shows how to use this method. the data on the child nodes of the DIV element are the ratings stars, and the msStarRating property gives the value of the rating (Windows only).


 <div id="ratingDiv" data-win-control="WinJS.UI.Rating"></div>
<script type="text/javascript">
    WinJS.UI.processAll();
    var div = document.getElementById("ratingDiv");
    var children = div.childNodes;

    var i = 0;
    while (i < children.length) {
        var child = children[i++];
        if (WinJS.Utilities.hasClass(child, "win-star")) {
            var rating = WinJS.Utilities.data(child);
            var value = rating.msStarRating;
        }
    }
</script>

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.Utilities

Library

Base.js

 

 

Show:
© 2014 Microsoft