Created
September 27, 2014 04:49
-
-
Save allthetime/292427cc0d9799cc9cf7 to your computer and use it in GitHub Desktop.
RATY STARTER KIT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="/" method="post"> | |
<!-- the stars are here in an empty div --> | |
<div id="rate" name="raty"></div><br> | |
<!-- this is the hidden input that raty sends the data to --> | |
<input type="number" name="rating" style="display:none;" id="rating"> | |
<input type="submit"> | |
</form> | |
<!-- do this for static ratings --> | |
<div class="rating" data-score="<%= review.rating %>"></div> | |
<script src="../javascript/application.js"></script> | |
<script> | |
//FOR THE FORM SELECTABLE STARS | |
$('#rate').raty({ | |
click: function(score, evt) { | |
$('#rating').val(score) | |
}}); | |
//FOR THE STATIC STARS | |
$.each($('.rating'), function( index, object ) { | |
$(object).raty({ | |
readOnly: true, | |
number: 5, | |
// grabs the 'data-score' for div class="rating" and sets the number of stars | |
score: $(object).attr('data-score') | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment