How to programmatically fire a dblclick event defined with addEventListener?
You can use dispatchEvent
to programatically trigger events:
var event = new MouseEvent('dblclick', {
'view': window,
'bubbles': true,
'cancelable': true
});
document.getElementById('aa').dispatchEvent(event);
See the section "Triggering built-in events" on MDN.
Here is a fiddle of the code in action.
This should work:
var doubleClickEvent = document.createEvent('MouseEvents');
doubleClickEvent.initEvent('dblclick', true, true);
e.currentTarget.dispatchEvent(doubleClickEvent); // inside method