If you're passing an object to .on()
to list more than one event you can (as with any JavaScript object literal) put the property names in quotes if you need the property names to include a dot:
$(window).on({
"keyup.modalKeyClose" : function (e) {
applyKeyEvents(e, modal);
},
"click.modalClickClose" : function (e) {
applyMouseEvents(e, modal);
}
});
According to the .off()
documentation you can remove multiple handlers with one call by listing all the handlers in the same string, with or without namespaces:
$(window).off("keyup.modalKeyClose click.modalClickClose");
Note that if you were to give both of your events the same namespace:
$(window).on({
"keyup.modalClose" : function (e) {
applyKeyEvents(e, modal);
},
"click.modalClose" : function (e) {
applyMouseEvents(e, modal);
}
});
...then you could remove them by specifying just the namespace:
$(window).off(".modalClose");