Reputation: 14025
According to the JQuery documentation, a namespace can be declare like this to be used with on
and off
:
var validate = function () {
// code to validate form entries
};
// delegate events under the ".validator" namespace
$("form").on("click.validator", "button", validate);
$("form").on("keypress.validator", "input[type='text']", validate);
// remove event handlers in the ".validator" namespace
$("form").off(".validator");
But how to declare a namespace for a multi events declaration in order to unbind them later using off()
?
$('#frame-right').on('mousewheel DOMMouseScroll MozMousePixelScroll',function(event){
event.preventDefault();
return false;
});
$('#frame-right').off(???)
Upvotes: 1
Views: 154
Reputation: 262979
You have to add the namespace to each individual event name:
$("#frame-right").on(
"mousewheel.ns DOMMouseScroll.ns MozMousePixelScroll.ns",
function(event) {
event.preventDefault();
return false;
}
);
Then you can issue:
$("#frame-right").off(".ns");
Upvotes: 2