When we jump from one jsxgraph sketch to another, some processes continuous to work in the background. I would like to know what is the best way of kill all event listeners in jsxgraph.js. For example, in the case of "update hooks" we can use the JXG.Board method removeHook(). But this method is deprecated in favor of JXG.Board.off(). On the other hand, the methods JXG.Board.off() and JXG.Board.on() do not have any documentation.
Anyway, my question is how can I kill all running eventHandlers and processes associated with a given board, before a jump to the next sketch.
Thanks!
The documentation for JXG.Board.on() and JXG.Board.off() is at https://jsxgraph.org/docs/symbols/JXG.EventEmitter.html.
The recommended way to get rid of all event listeners is to call
JXG.JSXGraph.freeBoard(board)and init a new board.In order to only remove all event listeners on JSXGraph elements and on the board itself - without removing the board - a cumbersome way (like in general JavaScript code) is to call
offin the same way as theonmethod for all event listeners.A very hacker-like method would be to set
This should remove all event listeners on JSXGraph elements on the whole HTML page.