Accepted answer

You seemed to be trying to do some kind of nested dragging or something, the following should work:

 var drag1 = d3.behavior.drag()
    .on("drag", dragmove)
    .on("dragend", function () { alert("drag ended"); });

Full example:


Quick mention if anyone still needs something like this, d3.behaviour was deprecated as well as dragend. If you still need the functionality it should look something like this:

d3.drag().on("end", (_event, dimension) => {
    console.log("alert ended for : " dimension)

(for more informations:

Related Query

More Query from same tag