Skip to content

Instantly share code, notes, and snippets.

@HenrikJoreteg
Created December 7, 2010 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HenrikJoreteg/732048 to your computer and use it in GitHub Desktop.
Save HenrikJoreteg/732048 to your computer and use it in GitHub Desktop.
For single page apps with lots of dnd, disable selectable, turn on for exceptions.
<!DOCTYPE html>
<html>
<head>
<title>Some single page app</title>
<style>
/*
Here's the magic, we take the unselectable attribute and make it more powerful
in browsers that support it see here for more:
http://help.dottoro.com/lcrlukea.php#-webkit-user-select
*/
[unselectable=on] {
-moz-user-select: none;
-webkit-user-select: none;
}
[unselectable=off] {
-moz-user-select: auto;
-webkit-user-select: auto;
}
/* enable it for p tags (for example) */
p {
-moz-user-select: auto;
-webkit-user-select: auto;
}
</style>
</head>
<body unselectable="on">
<ul class="draggable items">
<li>first non-selectable draggable</li>
<li>second non-selectable draggable</li>
</ul>
<p>Nothing here is selectable</p>
</body>
</html>
@westonruter
Copy link

You should do this on jsFiddle so we can play with it :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment