What is disableSelection used for in jQuery UI?

JqueryJquery Ui

Jquery Problem Overview


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

$( "#sortable" ).disableSelection();

Jquery Solutions


Solution 1 - Jquery

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.

Solution 2 - Jquery

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.

Solution 3 - Jquery

jQuery documentation says to not use it http://api.jqueryui.com/disableselection/

Also, I found that it made elements with contenteditable="true" no longer editable.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNikolaView Question on Stackoverflow
Solution 1 - JquerykbaView Answer on Stackoverflow
Solution 2 - JqueryDomQView Answer on Stackoverflow
Solution 3 - JqueryShane RowattView Answer on Stackoverflow