Skip to content

Instantly share code, notes, and snippets.

@amboy00
Created April 17, 2014 11:31
Show Gist options
  • Save amboy00/10975926 to your computer and use it in GitHub Desktop.
Save amboy00/10975926 to your computer and use it in GitHub Desktop.
Prevent bubbling in knockout
ko.bindingHandlers.noBubble = {
init: function(element, valueAccessor) {
var eventName = ko.utils.unwrapObservable(valueAccessor());
ko.utils.registerEventHandler(element, eventName, function(event) {
event.cancelBubble = true;
if (event.stopPropagation) {
event.stopPropagation();
}
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment