使用 jQuery UI Selectable 实现多选 [英] Implement multiple selects with jQuery UI Selectable

查看:41
本文介绍了使用 jQuery UI Selectable 实现多选的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮我使用 jquery ui 可选库来执行以下功能:

can anyone help me use the jquery ui selectable library to perform the following functions:

  • 允许用户通过单击鼠标选择多个项目
  • 取消选择一个项目,如果它已经通过鼠标点击被选中

推荐答案

这已在 另一个问题,但我在这里重新发布给通过谷歌找到这个的任何人.如果你在 jQuery 中绑定mousedown"事件并在那里设置 metaKey(就像用户按住 ctrl/cmd 键一样),那么当你调用 selectable 时,它​​已经被设置了.

This is worked around in another question, but I'm reposting here for anyone who finds this via google. If you bind the "mousedown" event in jQuery and set metaKey there (as if the user is holding the ctrl/cmd key), then when you call selectable, it will already be set.

$(".YOUR_SELECTOR_HERE").bind("mousedown", function(e) {
  e.metaKey = true;
}).selectable();

这篇关于使用 jQuery UI Selectable 实现多选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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