Aracılığıyla paylaş


Rating.onchange event

Raised when the user commits a change to the userRating.

Syntax

<div data-win-control="WinJS.UI.Rating" 
    data-win-options="{onchange : handler}">
</div>
function handler(eventInfo) { /* Your code */ }
 
// addEventListener syntax
rating.addEventListener("change", handler);
rating.removeEventListener("change", handler);

Event information

Synchronous No
Bubbles No
Cancelable Yes

 

Event handler parameters

  • eventInfo
    Type: CustomEvent**

    An object that contains information about the event. The detail property of this object contains the following sub-properties:

Remarks

Setting event handlers declaratively (in HTML)

To set the event handler declaratively, it must be accessible to the global scope, and you must also call WinJS.Utilities.markSupportedForProcessing or WinJS.UI.eventHandler on the handler. You can make the handler accessible to the global scope by using WinJS.Namespace.define. For more information, see How to set event handlers declaratively.

Examples

This example defines a handler for the onchange event. When the user changes the rating, it outputs the new rating value (obtained from eventInfo.detail.tentativeRating) to a div element.

function ratingChanged(eventInfo) {
    var ratingOutputDiv = document.getElementById("ratingOutputDiv");
    ratingOutputDiv.innerText = eventInfo.detail.tentativeRating;
}
WinJS.UI.eventHandler(ratingChanged);

WinJS.Namespace.define("startPage", {
    ratingChangedHandler: ratingChanged
});

The next example creates Rating control, sets the onchange event, and creates the output div in HTML.

<div id="ratingControlHost" 
    data-win-control="WinJS.UI.Rating" 
    data-win-options="{onchange: startPage.ratingChangedHandler}">
</div>
<div id="ratingOutputDiv">&nbsp;</div>

Requirements

Minimum WinJS version

WinJS 1.0

Namespace

WinJS.UI

See also

Rating

Quickstart: Adding WinJS controls