Rating.onchange event

Raised when the user commits a change to the userRating.


<div data-win-control="WinJS.UI.Rating" 
    data-win-options="{onchange : handler}">
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:


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.


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.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-options="{onchange: startPage.ratingChangedHandler}">
<div id="ratingOutputDiv">&nbsp;</div>


Minimum WinJS version

WinJS 1.0



See also


Quickstart: Adding WinJS controls