Reputation: 1
I am trying to disable the mousedown event with javascript. I am trying to modify a project of github so I don't know exactly the event function name. I can disable it through firefox,chrome tool but I cannot disable it programmaticaly. I have tried
$('.konvajs-content').off('mousedown');
$(".konvajs-content").onmousedown = null;
$(".konvajs-content").on("mousedown", function(e){
e.preventDefault();
e.stopImmediatePropagation();
e.returnValue = false;
});
It seems like another event is created but the event from Konva is not disabled. This is the image of my console log and the event I want to disable
Upvotes: 0
Views: 125
Reputation: 861
I answered a similar question here, making a little change you can desable/delete the mousedown
event only:
$(".class1").on("mousedown", () => {
console.log("mousedown");
});
function deleteEvent() {
const a = document.getElementsByClassName("class1")[0];
const regex = new RegExp(/jQuery\d*/);
for (const key in a) {
if (regex.test(key)) {
delete a[key].events.mousedown;
return;
}
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button class="class1">button</button>
<button class="class2" onclick="deleteEvent()">remove event from button</button>
Upvotes: 0