Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent selecting text in AngularJS on ng-dblclick?

I have an element with ng-dblclick='doSomthing()' which works fine, but has the ugly side effect of selecting the text in the element too. It there any way to prevent this?

like image 588
nickponline Avatar asked Mar 06 '14 02:03

nickponline


People also ask

How do you prevent the user from selecting the text rendered?

You can use the user-select property to disable text selection of an element. In web browsers, if you double-click on some text it will be selected/highlighted. This property can be used to prevent this.

How to prevent text selection on double click?

If you are trying to completely prevent selecting text by any method as well as on a double click only, you can use the user-select: none css attribute.

How to avoid double click in AngularJS?

So to prevent a double submit I could set a flag to buttonclicked = true when a button is click and unset it when the ajax callback is finished. But, even then control is handled back to angular who will updates to the Dom.

How to stop highlighting text when clicking CSS?

To disable text selection highlighting in Google Chrome browser using CSS just set -user-select CSS property to none.


1 Answers

Try to add these css rules to your class or div that you want to prevent the text selection of

.myClass {
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
}
like image 92
njtman Avatar answered Oct 24 '22 12:10

njtman