jQuery UI的星级评分小部件 [英] Star Rating widget for jQuery UI

查看:152
本文介绍了jQuery UI的星级评分小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

向我介绍了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?

尝试使用jquery UI之一,我无法使输入按钮显示为星星.我有这些js和CSS文件:

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" />

对于我的代码,只需:

<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,所以不确定是否需要该文件.我不确定是否也需要它,我使用的另一个星级插件也不需要它.有人知道我缺少什么吗?

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?

推荐答案

我发现,我下载的版本的问题是,_init函数中的对象o没有初始化好(默认值从ui末尾开始) .star.js未加载).该对象还设置CSS值(类).我还没有找到解决方案,但是一个简单的解决方法是在初始化页面上的星号时填充这些值:

I found out, that problem with the versoion I have downloaded is, that object o is not initialized ok 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>

这篇关于jQuery UI的星级评分小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆