jQuery ui Selectable()需要ctrl+点击选择,但我想拖拽+多点击选择

jQuery ui Selectable() need ctrl+click to select but I want draggable+ multi click to select

本文关键字:选择 多点 ui 需要 ctrl+ jQuery Selectable      更新时间:2023-09-26

我使用的是jQuery-ui的selectable(),它对我来说是完美的,同时点击ctrl+点击和拖动。

但是我想把Ctrl+click改成只点击一次,而且这个点击也选择了我的正方形行

这里是一个例子,其中单击选择正方形。我需要这个。http://www.social-contests.com/check-image/

非常感谢……

$cover.selectable({
        stop: function () {
            var total = $('.square').size();
            var selected = $('.square.ui-selected').size();
            var percent = Math.round(selected * 100 / total);
            var alert = $('#score').find('.alert').addClass('hide');
            if (percent <= 20) {
                $('#score').find('.alert-success').removeClass('hide');
            } else {
                $('#score').find('.alert-error').removeClass('hide');
            }
            $("#score").find('span.score-value').html(percent);
        }
    });

这并不容易:)但我想我找到了解决方案。我不得不深入研究源代码,我发现我们可以模拟我们按下ctrlKey。解决方法其实很简单:

event.originalEvent.ctrlKey = true;

注意如果您这样设置true:

event.ctrlKey = true;

它将不起作用。

http://jsfiddle.net/awguykk4/