jQuery UI的星级评分小部件

编程入门 行业动态 更新时间:2024-10-28 09:17:51
本文介绍了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的星级评分小部件

本文发布于:2023-11-25 01:33:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627768.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:星级   部件   评分   jQuery   UI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!