Disabling ctrl-click by jquery ui of choice

I was wondering if there is an option for jQuery UI Selectable that will allow me to disable Ctrl + Click, but still keep the drag and drop for multiple selection. In my project, I want people to be able to select plurals, but only by drag and drop, and not by Ctrl + click.

If this does not happen, does anyone know a way that I can achieve this?

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

+8
jquery jquery-ui jquery-ui-selectable
source share
3 answers

The selector uses the metaKey flag to perform multiple selections, so you can bind metaKey to the mousedown false method before calling selectable. Then Ctrl + click will always be turned off. Be sure to bind yourself before calling selectable, though.

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

jsFiddle here

+11
source share

There is another use of this good solution above - if you want to be able to simply use the mouse click to make all selections / deselects, without having to hold Ctrl for multi-selections or to deselect - always set the e.metaKey from the EvilAmarant7x example to true. That was exactly what I needed.

Edit: Apparently, someone already thought about this: Deploy multiple selections using jQuery UI Selectable :)

+3
source share
 $("#selectable").on("selectablestart", function (event, ui) { event.originalEvent.ctrlKey = false; }); 
+1
source share

All Articles