Rating

small
default
large
poor (value <= 2)
regular (value > 2 and <= 4)
good (value > 4)
Declarative style

                <div class="rating" data-role="rating"></div>
            
Javascript style

                <div class="rating" id="rating"></div>

                <script>
                    $(function(){
                        $("#rating").rating();
                    });
                </script>
            

Options

Parameter Data-* Type Default value Description
star data-stars int 5 Stars count
value data-value float 0 Rating value
half data-half boolean true Can be half value
static data-static boolean false If true rating show as static
showScore data-show-score boolean true Show or hide score label
scoreTitle data-score-title string Current: Score label title
size data-size string default Rating size [default, small, large]
colorRate data-color-rate boolean false If true rating is displayed in color depending on the values

Events

Event Data-* Params Description
onRate data-on-rate (value, star, widget) The event fired when the star click. This function can return true or false. If function return false, rating not changed
onRated data-on-rated (value, star, widget) The event fired when the star is pressed and onRate return true

Methods

Method Description Method call
value Set or get rating value get value $("#itemid").rating('value') or $("#itemid").data('metro.rating').value()
set value $("#itemid").rating('value', val) or $("#itemid").data('metro.rating').value(val)