Skip to content

Instantly share code, notes, and snippets.

@lplume
Created January 5, 2011 14:13
Show Gist options
  • Save lplume/766364 to your computer and use it in GitHub Desktop.
Save lplume/766364 to your computer and use it in GitHub Desktop.
jQuery ui sortable & selectable wating jQueryUi 1.9 milestone, i put together piece of code here and there (from the web) as a workaround to get an element both sortable and selectable. Be careful... This is really a workaround..
/**
* Disable sortable while target element fired
* - mouseover event AND
* - CTRL keydown
*/
var jid_element = "#" + myElement;
var isCtrl = false;
var isOver = false;
$(jid_element).mouseover(function() {isOver = true});
$(jid_element).mouseout(function() {isOver = false});
$(document).keyup(function (e) {
if(e.which == 17) {
isCtrl=false;
isOver=false;
$(jid_element).sortable({disabled:false});
}
});
$(document).keydown(function (e) {
if(e.which == 17) isCtrl=true;
if(isCtrl && isOver) {
$(jid_element).sortable({disabled:true});
$(jid_element).selectable();
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment