jQuery UI 中的 disableSelection 用于什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6426795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is disableSelection used for in jQuery UI?
提问by Nikola
Can someone help me understand why is this useful and when to use it?
有人可以帮助我理解为什么这很有用以及何时使用它吗?
$( "#sortable" ).disableSelection();
回答by kba
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.
如果您想让文本不可选择,这会很有用。例如,如果您想制作带有文本的拖放元素,如果在尝试拖动框时意外地选择了框上的文本,那么用户就会很烦。
回答by DomQ
Caveat emptor: .disableSelection()
is actually harmful on some browsers, as it prevents clicking active elements (e.g. textarea
s) inside the sortable.
警告清空器:.disableSelection()
实际上在某些浏览器上是有害的,因为它会阻止单击textarea
sortable 内的活动元素(例如s)。
- Firefox 33.1 for Mac OS X (Yosemite):
.disableSelection()
prevents clicking on embeddedtextarea
; 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.
- Firefox 33.1 for Mac OS X (Yosemite):
.disableSelection()
防止点击内嵌textarea
;否则似乎没有任何影响(即如果省略,仍然无法在可排序中使用鼠标选择文本) - 适用于 Mac OS X 的 Chrome 39.0.2171.71(64 位):
.disableSelection()
似乎没有任何影响。
回答by Shane Rowatt
jQuery documentation says to not use it http://api.jqueryui.com/disableselection/
jQuery 文档说不要使用它http://api.jqueryui.com/disableselection/
Also, I found that it made elements with contenteditable="true"
no longer editable.
此外,我发现它使元素contenteditable="true"
不再可编辑。