Class Rating

Lets the user rate something by clicking an icon that represents a rating. The Rating control can display three types of ratings: an average rating, a tentative rating, and the user's rating.

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(element?: HTMLElement, options?: any): Rating

Creates a new Rating.

constructor

Parameters

  • element?: HTMLElement optional

    The DOM element hosts the new Rating.

  • options?: any optional

    An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the cancel event, add a property named "oncancel" to the options object and set its value to the event handler.

Returns

Rating

Properties

public averageRating: number

Gets or sets the average rating.

public disabled: boolean

Gets or sets whether the control is disabled. When the control is disabled, the user can't specify a new user rating or modify an existing rating.

public element: HTMLElement

Gets the DOM element that hosts the Rating.

public enableClear: boolean

Gets or sets whether control lets the user clear the rating.

public maxRating: number

Gets or sets the maximum possible rating value.

public tooltipStrings: Array<string>

Gets or sets a set of descriptions to show for rating values in the tooltip.

public userRating: number

Gets or sets the user's rating.

Methods

public addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean)

Registers an event handler for the specified event.

Parameters

  • eventName: string

    The name of the event to handle.

  • eventHandler: Function

    The event handler function to associate with the event.

  • useCapture?: boolean optional

    Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase.

public dispose()

Releases resources held by this Rating. Call this method when the Rating is no longer needed. After calling this method, the Rating becomes unusable.

public oncancel(eventInfo: Event)

Raised when the user finishes interacting with the rating control without committing a tentative rating.

Parameters

  • eventInfo: Event

    An object that contains information about the event.

public onchange(eventInfo: CustomEvent)

Raised when the user commits a change to the userRating.

Parameters

  • eventInfo: CustomEvent

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

public onpreviewchange(eventInfo: CustomEvent)

Raised when the user is choosing a new tentative Rating.

Parameters

  • eventInfo: CustomEvent

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

public removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean)

Removes an event handler that the addEventListener method registered.

Parameters

  • eventName: string

    The name of the event that the event handler is registered for.

  • eventCallback: Function

    The event handler function to remove.

  • useCapture?: boolean optional

    Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler.