用户单击后更改JQuery Raty ReadOnly值

May*_*sam 3 jquery jquery-plugins

我想在Click事件中使Raty只读,但它不起作用:

            $('#number').raty({
            click: function(score, evt) {
                readOnly: true; //it does not work here
                $.get(
                "../../ajax/test.aspx",
                {r:score},
                function (data) { alert(data); },
                "html"
        );

                },
            scoreName: 'entity.score',
            number: 10

            });
Run Code Online (Sandbox Code Playgroud)

Raty主页

Khô*_*hôi 7

您需要取消绑定上的点击事件 img

$('#star').raty({
    click: function(score, evt) {
        $(this).find('img').unbind('click');
        // $(this).find('img').unbind(); <-- this removes all listeners
    }
});
?
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/xnZVd/

  • 我只删除了发送评级的点击事件.如果你想删除所有东西(即悬停在它们上面时星星会变化),你可以尝试`$(this).find('img').unbind();`.我还在http://sandbox.compile.ch上添加了一个完整的例子 (2认同)