The bootstrap-star-rating plugin supports the following events.
Not seeing the updated content on this page! Hard refresh your browser to clean cache for this page (e.g. SHIFT-F5 on Windows Chrome)
This event is triggered when the star rating is modified or changed
(this is in addition to the default change
event). This event also allows you to access
these parameters:
value
: the selected rating value
caption
: the caption for the selected rating
Example:
$('#input-id').on('rating:change', function(event, value, caption) { console.log(value); console.log(caption); });
This event is triggered when the rating is cleared with the clear button.
Example:
$('#input-id').on('rating:clear', function(event) { console.log("rating:clear"); });
This event is triggered when the rating is reset to initial value.
Example:
$('#input-id').on('rating:reset', function(event) { console.log("rating:reset"); });
This event is triggered, when the mouse (pointing input device) is hovered inside a star rating or the clear button. This event also allows you to access these parameters:
value
: the selected rating value
caption
: the caption for the selected rating
target
: the target for the hover - returns whether you hovered on the
stars
or the clear
button.
Example:
$('#input-id').on('rating:hover', function(event, value, caption, target) { console.log(value); console.log(caption); console.log(target); });
This event is triggered, when the mouse (pointing input device) is hovered out of a star rating or the clear button without clicking. This event also allows you to access these parameters:
target
: the target for the hover - returns whether you left hovering on the
stars
or the clear
button.
$('#input-id').on('rating:hoverleave', function(event, target) { console.log(target); });
This event is triggered, when the mouse (pointing input device) enters a specific star within the rating This event also allows you to access these parameters:
index
: int, the index of the star (starting from 1) where the mouse is hovered.
status
: string, the type of star hovered - can be one of filled-star
or empty-star
$star
: jQuery object, the jQuery object for the current star hovered. You can use this to retrieve HTML attributes of the star (e.g. $star.attr('title')
).
Example:
$('#input-id').on('rating:mouseenter', function(event, index, status, $star) { console.log(index); console.log(status); console.log($star); console.log($star.attr('title')); });
This event is triggered, when the mouse (pointing input device) leaves/ exits a specific star within the rating This event also allows you to access these parameters:
index
: int, the index of the star (starting from 1) where the mouse was hovered.
status
: string, the type of star hovered - can be one of filled-star
or empty-star
$star
: jQuery object, the jQuery object for the current star hovered. You can use this to retrieve HTML attributes of the star (e.g. $star.attr('title')
).
Example:
$('#input-id').on('rating:mouseleave', function(event, index, status, $star) { console.log(index); console.log(status); console.log($star); console.log($star.attr('title')); });
This event is triggered, when the rating has been focused via the keyboard or on click.
Example:
$('#input-id').on('rating:focus', function(event) { // do something });
This event is triggered, when one has blurred/ navigated out of the rating (typically via the keyboard) - thus removing its focus.
Example:
$('#input-id').on('rating:blur', function(event) { // do something });
This event is triggered, when one increments or decrements the rating using the keyboard RIGHT and LEFT arrow keys. This event also allows you to access these parameters:
value
: the selected rating value
caption
: the caption for the selected rating
Example:
$('#input-id').on('rating:blur', function(event, value, caption) { console.log(value); console.log(caption); });
Comments & Discussion
Note
You can now visit the Krajee Webtips Q & A forum for searching OR asking questions OR helping programmers with answers on these extensions and plugins. For asking a question click here. Select the appropriate question category (i.e. Krajee Plugins) and choose this current page plugin in the question related to field.
The comments and discussion section below are intended for generic discussions or feedback for this plugin. Developers may not be able to search or lookup here specific questions or tips on usage for this plugin.