Rating.onchange event

This topic has not yet been rated - Rate this topic

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

SynchronousNo
BubblesNo
CancelableYes

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:

detail.tentativeRating

The new userRating.

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 supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Namespace

WinJS.UI

Library

Ui.js

See also

Rating
Quickstart: Adding WinJS controls

 

 

Build date: 12/5/2012

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