This time I will share jQuery Plugin and tutorial about Fully Configurable jQuery Rating Control Plugin – Rater, hope it will help you in programming stack.
Rater is a simple yet highly customizable jQuery rating control plugin that features fractional star ratings, custom rating symbols, ajax handling, lots of configurations / API and much more.
How to use it:
1. Just download & include the jQuery Rater’s script after jQuery library and we’re ready to go.
1 |
< script src = "//code.jquery.com/jquery.min.js" ></ script > |
2 |
< script src = "rater.js" ></ script > |
2. Create a DIV placeholder for the rating control.
1 |
<div class= "rate" ></div> |
3. If you want to set the max rating value:
1 |
<div class= "rate" data-rate-value=6></div> |
4. Initialize the rating control with default options:
5. Customize the rating symbols:
14 |
fontawesome_beer: '<i class="fa fa-beer"></i>' , |
16 |
base: '<i class="fa fa-star-o"></i>' , |
17 |
hover: '<i class="fa fa-star"></i>' , |
18 |
selected: '<i class="fa fa-star"></i>' , |
21 |
base: [0x1F625, 0x1F613, 0x1F612, 0x1F604], |
22 |
hover: [0x1F625, 0x1F613, 0x1F612, 0x1F604], |
23 |
selected: [0x1F625, 0x1F613, 0x1F612, 0x1F604], |
26 |
selected_symbol_type: 'utf8_star' , |
6. More configuration options with default values.
05 |
convert_to_utf8: false , |
09 |
only_select_one_symbol: false , |
7. API methods:
01 |
$( ".rating" ).rate( "getValue" ); |
02 |
$( ".rating" ).rate( "setValue" ); |
03 |
$( ".rating" ).rate( "increment" ); |
04 |
$( ".rating" ).rate( "decrement" ); |
05 |
$( ".rating" ).rate( "getElement" , layer_name, element_index); |
06 |
$( ".rating" ).rate( "getLayers" ); |
07 |
$( ".rating" ).rate( "setFace" , value, face); |
08 |
$( ".rating" ).rate( "removeFace" , value); |
09 |
$( ".rate2" ).rate( "setAdditionalData" , {id: 42}); |
10 |
$( ".rate2" ).rate( "getAdditionalData" ); |
8. Events.
01 |
$( ".rating" ).on( "change" , function (ev, data){ |
02 |
console.log(data.from, data.to); |
05 |
$( ".rating" ).on( "updateSuccess" , function (ev, data){ |
06 |
console.log( "This is a custom success event" ); |
09 |
$( ".rating" ).on( "updateError" , function (ev, jxhr, msg, err){ |
10 |
console.log( "This is a custom error event" ); |
8. Destroy & remove the rating control.
1 |
$( ".rating" ).rate( "destroy" ); |
This awesome jQuery plugin is developed by auxiliary. For more Advanced Usages, please check the demo page or visit the official website.