Rate Yo!
RateYo! is a tiny and flexible jQuery star rating plugin, it uses SVG to render rating, so no images required.
just create a <div/>, throw some styles, initialize and thats it!.
Hover to change the rating and Click to set.
<-- HTML -->
<div id="rateYo"></div>
/* Javascript */
//Make sure that the dom is ready
$(function () {
$("#rateYo").rateYo({
rating: 3.6
});
});
Methods
All methods follow a common signature.
A method of the plugin can be called by passing the string
"method" as the first parameter,
name of the method as second parameter,
followed by arguments to the method.
If no arguments are passed after the method name, it is considered as a getter, else it is considered as a setter
destroy:
<!-- HTML -->
<div id="rateYo"></div>
<div>
<button id="destroy">Destroy</button>
<button id="initialize">Initialize</button>
</div>
/* Javascript */
$(function () {
var $rateYo = $("#rateYo").rateYo();
$("#destroy").click(function () {
$rateYo.rateYo("method", "destroy");
});
$("#initialize").click(function () {
$rateYo.rateYo();
});
});
Events
rateyo.set
This event shall be fired when ever the rating is set.
This new rating shall be passed in the second parameter to the event handler
<!-- HTML -->
<div id="rateYo"></div>
/* javascript */
$(function () {
$("#rateYo").rateYo()
.on("rateyo.set", function (e, data) {
alert("The rating is set to " + data.rating + "!");
});
});
rateyo.change
This event will be fired when ever the rating is change.
This new rating shall be passed in the second parameter to the event handler
<!-- HTML -->
<div id="rateYo"></div>
/* javascript */
$(function () {
$("#rateYo").rateYo()
.on("rateyo.change", function (e, data) {
var rating = data.rating;
$(this).next().text(rating);
});
});