Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is disableSelection used for in jQuery UI?

Can someone help me understand why is this useful and when to use it?

$( "#sortable" ).disableSelection();
like image 487
Nikola Avatar asked Jun 21 '11 14:06

Nikola


2 Answers

It's useful if you want to make text unselectable. If, for instance, you want to make drag-and-drop elements with text on, it'd be annoying to the user if the text on the box accidentally would get selected when trying to drag the box.

like image 98
kba Avatar answered Nov 20 '22 10:11

kba


Caveat emptor: .disableSelection() is actually harmful on some browsers, as it prevents clicking active elements (e.g. textareas) inside the sortable.

  • Firefox 33.1 for Mac OS X (Yosemite): .disableSelection() prevents clicking on embedded textarea; doesn't seem to have any effect otherwise (i.e. it is still impossible to select text with the mouse in the sortable if omitted)
  • Chrome 39.0.2171.71 (64-bit) for Mac OS X: .disableSelection() seems to have no effect whatsoever.
like image 26
DomQ Avatar answered Nov 20 '22 10:11

DomQ