I have created a simple drawing script using canvas: http://ulrichbangert.de/div/webentwicklung/javascript/jcanvas-drawing-pad.html I need event handlers and I attach them like this (very simplyfied):
<canvas id="mycanvas" width="400" height="300"></canvas>
<script>
var line = {
activate: function () {
$("#mycanvas").off();
$("#mycanvas").on("mousemove", function (e) {
// do something to draw line
})
}
}
var text = {
activate: function () {
$("#mycanvas").off();
$("#mycanvas").on("mousemove", function (e) {
// do something to draw text
})
}
}
line.activate();
// later on:
text.activate();
</script>
The problem is that I'm using the library jCanvas that attaches eventhandlers too. By
$("#mycanvas").off();
I remove all handlers including those attached by jCanvas, so that some features don't work. How can I remove the handlers attached by me and keep the library's handlers intact?