Bob
Bob

Reputation: 3084

JSTree DND Event at Drag Starting Point

I have a external draggable object (draggable implemented through jstee's dnd) on which I need to perform a check before the object starts dragging.

I'm looking for a method much like "drag_finish" or a binding I can use, but at the start of the dragging event.

Upvotes: 3

Views: 3842

Answers (3)

Sufiyan Ansari
Sufiyan Ansari

Reputation: 1946

drag_start.vakata has been changed to dnd_start.vakata Now the above event would be triggered on these Functions:

$(document).bind("drag_start.vakata", function (e, data) {
if (data.data.jstree) {
    //User started dragging
}});

$(document).bind("drag.vakata", function (e, data) {
if (data.data.jstree) {
    //User is dragging
}});

$(document).bind("drag_stop.vakata", function (e, data) {
if (data.data.jstree) {
   //User stopped dragging
}});

Upvotes: 0

Pike
Pike

Reputation: 119

Just as a more complete answer, here's some code for all 3 events (start, drag and stop):

$(document).bind("drag_start.vakata", function (e, data) {
    if (data.data.jstree) {
        //User started dragging
    }
});

$(document).bind("drag.vakata", function (e, data) {
    if (data.data.jstree) {
        //User is dragging
    }
});

$(document).bind("drag_stop.vakata", function (e, data) {
    if (data.data.jstree) {
       //User stopped dragging
    }
});

Upvotes: 1

Bob
Bob

Reputation: 3084

$(document).bind("drag_start.vakata", function (e, data) { 
  if(data.data.jstree) { 
    // add your code here 
  } 
}); 

Binding to the document did the trick

Upvotes: 2

Related Questions