我想在我的网站上添加星级评分。
这是我的cshtml标记
@{
ViewBag.Title = "דירוג";
Layout = "~/Views/Shared/_SubPage.cshtml";
ViewBag.Page = "Rating";
ViewBag.TabHeader = "דירוג";
}
@*=====css=====*@
<link href="@Url.Content("~/Resources/jquery.ui.stars-3.0/jquery.ui.stars.min.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Styles/Rating.css")" rel="stylesheet" type="text/css" />
<form>
Rating: <span id="stars-cap"></span>
<div id="stars-wrapper1" class="span4 oofset3">
<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>
<script src="@Url.Content("~/Resources/jquery.ui.stars-3.0/jquery.ui.stars.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Rating.js")" type="text/javascript"></script>
我在浏览器Dev-console中收到以下错误:
jquery.ui.stars.js:20 Uncaught TypeError: Object function (a,b){return new d.fn.init(a,b,g)} has no method 'widget' jquery-1.5.1.min.js:19 Uncaught TypeError: Object [object Object] has no method 'on'
更改为jquery 1.7.2后,我得到以下内容:
jquery.ui.stars.js:20 Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'widget' Rating.js:23 Uncaught TypeError: Object [object Object] has no method 'stars'
在用户界面中,我看到收音机盒,而不是开头。 我该如何解决这个问题?
答案 0 :(得分:2)
您的星级评分插件似乎正在使用on()方法注册事件处理程序。这个方法是在jQuery 1.7中引入的,你使用的是版本1.5.1,它不支持它。
将jQuery库升级到latest release(目前为1.7.2)可能会解决您的问题。