【问题标题】:How to set readOnly on a jRate plugin's param after make a click on a star单击星号后如何在 jRate 插件的参数上设置只读
【发布时间】:2015-03-17 21:04:22
【问题描述】:

我一直在思考如何在单击星号后将 de readOnly 参数设置为 de jRate 插件,但我找不到解决方案。

这是我一直在处理的代码:

$("#jRate").jRate({
    startColor: 'yellow',
    endColor: 'red',
    width: 17,
    height: 17,
    backgroundColor: 'black',
    min: 0,
    max: 5,
    precision: 0,
    /* Show rating when mouse over*/
    onChange: function (rating ) {
        $('#rating ').text(" " + rating );
        readOnly: true;
    },
    /*set a click's behavior*/
    onSet: function (readOnly) {
        //$('#demo-onset-value').text("Selected Rating: " + rating);
        readOnly: true;
        alert(readOnly); // just only to view readOnly value
    }
});

如您所见,我已尝试直接设置参数, 我尝试设置一个全局变量,如 var read = false,然后在“onSet”函数上设置 read = true 并返回该值,所以最后设置 只读:onSet();

现在,我无法在单击后设置 readOnly 变量。是的,我只能在 onSet() 函数之前设置变量 readOnly: true 但这只会使星星禁用。

这个插件是为了做一个视觉的“星星”评级,比如:* * * * *

问候!!!

【问题讨论】:

    标签: javascript jquery jquery-plugins


    【解决方案1】:

    你可以这样做rater.setReadOnly(true);

    var rater = $("#jRate").jRate({
      rating: 3,
      strokeColor: 'black',
      width: 80,
      height: 80,
      onSet: function(rating) {
        rater.setReadOnly(true);
      }
    });
    

    这是demo

    【讨论】:

    • 回答!!!!这就是这样做的确切方法。非常感谢Dhiraj !!!我喜欢堆栈溢出:)
    • 请将其标记为已回答,以便其他人可以从中受益。鉴于 jRate 网站没有足够的相关文档。
    猜你喜欢
    • 2018-05-04
    • 1970-01-01
    • 1970-01-01
    • 2020-11-09
    • 1970-01-01
    • 2012-06-05
    • 2020-05-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多