I’ve used .on() to bind a keydown event in Dojo. After the event fires, I need to unbind the event, and nothing seems to work. Their documentation says that the event returns an object that has a .remove() method, but I cannot for the life of me figure out how to access or apply this method.
Any help would be greatly appreciated.
Thanks!
query('#video-topics-input').on('keydown',function(e){
topicsDrop.keyDownFunc(e, e.keyCode);
});
dojo.on returns an event-handle which has the said .remove function to unbind a listener. in your case however, youre using a chained dojo.query which operates on a dojo.NodeList.
This basically means that you must think in terms of arrays, your above example would return an array with one entry – since selector is an ID.
To bind eventlistener:
And to unbind these:
A more efficient approach would be to not use query to look up byId though