June 08, 2013

Knockout custom binding to filter multiple mouse clicks

Knockout custom bindings offer a useful extension point for interacting with the DOM, without compromising the testability of View Models. Here is a binding handler to filter unwanted double/triple/multiple mouse clicks, using debounce - an Underscore.js function.

(If you don't want to include Underscore.js in your project, just lift out the debounce function which is only about 15 lines of Javascript and isn't dependent on any Underscore library internals).

No comments:

Post a Comment