Star Rating widget for jQuery UI
I was introduced to the Star Rating widget for jQuery UI. I was originally using this one.
Is there any difference between using the two?
Well trying to use the jquery UI one, I can't get the input buttons to show up as stars. I have these js and css files included:
<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
<script src="ui.stars.js" type="text/javascript"></script>
<link href="ui.stars.css" type="text/css" rel="stylesheet" />
And for my code, simply:
<form>
Rating: <span id="stars-cap"></span>
<div id="stars-wrapper1">
<input type="radio" name="newrate" value="1" title="Very poor" />
<input type="radio" name="newrate" value="2" title="Poor" />
<input type="radio" name="newrate" value="3" title="Not that bad" />
<input type="radio" name="newrate" value="4" title="Fair" />
<input type="radio" name="newrate" value="5" title="Average" checked="checked" />
<input type="radio" name="newrate" value="6" title="Almost good" />
<input type="radio" name="newrate" value="7" title="Good" />
<input type="radio" name="newrate" value="8" title="Very good" />
<input type="radio" name="newrate" value="9" title="Excellent" />
<input type="radio" name="newrate" value="10" title="Perfect" />
</div>
</form>
All the files a开发者_JS百科nd images are in the same folder. I've never used jquery UI before, so I'm not sure if all I need is that file. I'm not sure if it needs it either, the other star rating plugin I was using didn't require it. Anyone know what I'm missing anything?
When using orkans' star_rating you need to tell it to convert radiobuttons to stars explicitly, like this (I use jQuery.noConflict mode):
jQuery(document).ready(function($){
$("#stars-wrapper1").stars();
}
I found out, that problem with the version I have downloaded is, that object o
is not initialized in the _init
function (the defaults from the end of ui.star.js
are not loaded). This object also sets the CSS values (classes). I haven't found the solution yet, but a simple workaround would be, to fill those values at initialization of stars on your page:
<script type="text/javascript">
$("#stars-wrapper1").stars({
cancelClass: "ui-stars-cancel",
starClass: "ui-stars-star",
starOnClass: "ui-stars-star-on",
starHoverClass: "ui-stars-star-hover",
starDisabledClass: "ui-stars-star-disabled",
cancelHoverClass: "ui-stars-cancel-hover",
cancelDisabledClass: "ui-stars-cancel-disabled"
});
</script>
usually jquery ui css files refer images from folder named images
put is same directory as css file. So you need to either change path of refered images in ui.stars.js.
|
--images
|
---image files are here
|
--ui.stars.css
精彩评论