jQuery UI 的星级评定小部件
我被介绍给 jQuery UI 的星级小部件。 我最初使用的是这个。
两者使用有什么区别吗?
尝试使用 jquery UI 时,我无法让输入按钮显示为星星。我包含这些 js 和 css 文件:
<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" />
对于我的代码,简单地说:
<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>
所有文件和图像都在同一个文件夹中。我以前从未使用过 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 and 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当使用 orkans 的 star_ rating 时,你需要告诉它显式地将单选按钮转换为星号,如下所示(我使用 jQuery.noConflict 模式):
When using orkans' star_rating you need to tell it to convert radiobuttons to stars explicitly, like this (I use jQuery.noConflict mode):
我发现,我下载的版本的问题是,对象
o
没有在_init
函数中初始化(默认值是ui.c 末尾的默认值)。 star.js 未加载)。该对象还设置 CSS 值(类)。我还没有找到解决方案,但一个简单的解决方法是在页面上的星星初始化时填充这些值:
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 ofui.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:通常 jquery ui css 文件引用名为
images
的文件夹中的图像,并将其与 css 文件放在同一目录中。因此,您需要更改 ui.stars.js 中引用图像的路径。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.