In this jsFiddle. I want to add prevent drag and drop functionality if TR is changed of the element.
Elements can be dragged and dropped in their own TR only. How can I do this?
Should I add some restriction in accept method ?
Following is the JS code:
$(function() {
$(".dragDiv").draggable({
revert: 'invalid'
});
$(".mainTable tr td").droppable({
accept: function() {
var $this = $(this);
console.log(JSON.stringify($this.data("parent-id")+'==='+$this.parent().attr("id")));
if (($this.data("parent-id") == $this.parent().attr("id")) && $(this).find("*").length == 0)
{
return true;
}
else
{
return false;
}
},
drop: function(event, ui) {
var $this = $(this);
$this.append(ui.draggable.css({
top: 0,
left: 0
}));
ui.draggable.position({
my: "center",
at: "center",
of: $this,
using: function(pos) {
$(this).animate(pos, "slow", "linear", function() {
});
}
});
}
});
});