How to trigger dragend event

Viewed 33

How do I force a dragend event to fire? I use a library that automatically adds a listener to elements which looks for a long press (for touch screen to simulate a right click event). I don't want that to fire when a user tries to drag (but the nature of dragging means, they click and hold/long press)

I know how to set one up, but what I'd like is

instrumentInfo.addEventListener("dragstart", function (e) {
    e.preventDefault();//stop longpress working for touch screens
    e.dragend(); //not going to work
    instrumentInfo.dispatchEvent("dragend");//does not work
    instrumentInfo.dispatchEvent(new Event("dragend"));//no exception but does not seem to work
}

I understand I may get race conditions and am OK with that

1 Answers

And the answer is, execute the mouseup event

instrumentInfo.dispatchEvent(new Event("mouseup"));
Related