评级评分未正确显示
Posted
技术标签:
【中文标题】评级评分未正确显示【英文标题】:raty rating score not properly displayed 【发布时间】:2016-03-16 07:59:31 【问题描述】:我使用 rate 插件来显示多个项目的星级。我初始化了一个数据属性的评分,比如
<span class="rating_score" data-rating=" review.rating" ></span>
然后我跑遍了所有的课程,然后我开始了速度
jQuery(".rating_score").each(function()
$_this = jQuery(this);
console.log(($_this.attr('data-rating') ));
jQuery(this).raty(
path: '/bundles/gfx/rating/',
starOn: 'star.gif',
starOff: 'star_empty.gif',
hintList: ['1', '2', '3', '4', '5'],
scoreName: 'rating',
start: ($_this.attr('data-rating') ),
width: 13,
readOnly: true
);
);
问题是每个项目显示的评分值都是一样的,sn-p有什么问题
【问题讨论】:
【参考方案1】:试试这个(请参阅评论了解我所做的更改):
jQuery(".rating_score").each(function()
$_this = jQuery(this);
jQuery(this).raty(
starOn: 'star', // this should be a class name with your class styling the star image rather than a gif
starOff: 'star_empty', // this should be a class name with your class styling the empty star image rather than a gif
hintList: ['1', '2', '3', '4', '5'],
scoreName: 'rating',
score: $_this.attr('data-rating'), // instead of start, use score and remove the brackets
readOnly: true // remove this if you want to be able to select a new rating
);
);
.rating_scrore
display: block;
.star,
.star_empty
display: inline-block;
width: 15px;
height: 15px; /* change width & height to match star gif dimensions*/
.star
background: red; /*change this to be you star.gif*/
.star_empty
background: blue; /*change this to be you star_empty.gif*/
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://jacob87.github.io/raty-fa/lib/jquery.raty-fa.js"></script>
<span class="rating_score" data-rating="1"></span><br />
<span class="rating_score" data-rating="2"></span><br />
<span class="rating_score" data-rating="3"></span><br />
<span class="rating_score" data-rating="4"></span><br />
Example where you can select a new rating
【讨论】:
感谢您的反馈和帮助评分星级未选择值 我将raty更新到最新版本,现在可以使用score了,非常感谢!以上是关于评级评分未正确显示的主要内容,如果未能解决你的问题,请参考以下文章