禁用Ctrl并单击可选择的jQuery UI [英] Disabling ctrl-click on jquery ui selectable

查看:118
本文介绍了禁用Ctrl并单击可选择的jQuery UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道jQuery UI Selectable上是否有一个选项可以让我禁用 Ctrl + Click,但仍保持可拖动状态以进行多重选择.在我的项目中,我希望人们能够选择多个,而只能通过拖动来选择,而不是通过 Ctrl +单击来选择.

I was wondering if there is an option on the jQuery UI Selectable that will let me disable the Ctrl+Click, but still keep the draggable for the multiple selection. On my project I want to be able for people to select multiples, but only by dragging, not by Ctrl+clicking.

如果没有,没有人知道我可以实现这一目标的方法吗?

If there isn't, does anyone know a way I can achieve this?

任何信息都将非常有帮助! :)谢谢!!!

Any information would be really helpful! :) Thanks!!!

推荐答案

Selectable使用metaKey标志进行多选,因此您可以在调用selectable之前将metaKey绑定为false.然后, Ctrl +单击将始终处于关闭状态.不过,在调用selectable之前,请确保绑定.

Selectable uses the metaKey flag to do multi-select, so you can bind metaKey to be false on the mousedown before calling selectable. Then Ctrl+click will always be off. Make sure to bind before calling selectable though.

$('#selectable').bind("mousedown", function (e) {
            e.metaKey = false;
 }).selectable()

jsFiddle 此处

jsFiddle here

这篇关于禁用Ctrl并单击可选择的jQuery UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆