I'm using Denis' outstanding tableDnD jquery plugin. I would like to allow users to drag/drop rows but only when their mouse is within a particular td within the row.
So far I've tried two methods:(note that the var "tr" contains the jquery row element I'm operating on. the td id="queue_position" is the one I'm trying to enable dragging for).
I think that tableDnD only checks for the nodrag class when it starts up. adding or deleting the nodrop class dynamically doesn't change anything. So I tried two ways to do what I need to do.
Attempt one was to dive into tableDnD internals and try to call it's makeDraggable function. Attempt two was to re-initialize tableDnD after adding/removing the nodrop class.
Either of these methods seems to work to enable dragging when in the allowed td. Neither of them properly disables dragging when leaving the td. Once a row is enabled in the mouseenter event it stays enabled forever.
I'd prefer to find a way to do what I need without modifying tableDnD.
Any suggestions on how to make this work?
$(tr)
.addClass("nodrag")
.find("td[id='queue_position']")
//.on("mouseenter",function() {
// $(tr).removeClass("nodrag");
// $.tableDnD.makeDraggable(document.getElementById("tableLeft"));
//})
//.on("mouseleave",function() {
// $(tr).addClass("nodrag");
// $.tableDnD.makeDraggable(document.getElementById("tableLeft"));
//});
.on("mouseenter",function() {
$(tr).removeClass("nodrag");
$("#tableLeft").tableDnD({onDrop: handleDragDrop});
})
.on("mouseleave",function() {
$(tr).addClass("nodrag");
$("#tableLeft").tableDnD({onDrop: handleDragDrop});
});