开发者

jQuery Raty: how to disable one rating box in a group of rating boxes?

I'm using the jQuery Raty plugin which is a nice and rather complete plugin to create ratings (A row with some clickable stars like in iTunes).

In the project I'm working on I have a number of elements (images) that all contain a rating box. On HTML level these rating boxes all have the same classname so the Raty plugin can activate them in one call: $('.rating').raty

This call also makes it possible to disable (make 'readonly') these rating boxes, but the command disables ALL rating boxes. What I would like to do is to activate the rating boxes using th开发者_C百科e aforementioned command, AND disable one or more of the rating boxes inside that group.

Anyone know if this is possible?


If you want to adjust the settings while the code is running, you can do this:

var isEven = false;

$('.raty').each(function(i) {

    isEven = (++i % 2 == 0);

    $(this).raty({
        readOnly: isEven,
        start: (isEven) ? 3 : 0 
    });

});

If you already have the code and want to change it later, you can do this:

$(function() {
    var targetID = $('.raty').attr('id');

    $.fn.raty.start(5, '#' + targetID);
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜