Is there a way to separate a click events functionality from a drag events functionality if they are both attached to the same object?
I am adding a class on click. My goal for my application is that when a user has 'clicked' and item, that it's draggable functionality is disabled.
Conversely, if a user drags an item, the click should not fire off.
Is this possible?
Here's my fiddle with the code below included...
html:
<div class="buttonBox"></div>
jQuery:
var bool = false;
var buttonBox = $(".buttonBox");
buttonBox.off("click");
buttonBox.on("click", function (event, ui) {
console.log("class Added");
$bool = true;
var self = $(this);
self.addClass("selectedBox");
});
buttonBox.draggable({
distance: 40,
disabled: bool,
revert: "invalid",
revertDuration: 400,
refreshPositions: true,
});