Skip to content

Instantly share code, notes, and snippets.

@matthewnitschke
Created October 30, 2016 19:18
Show Gist options
  • Select an option

  • Save matthewnitschke/4f4896e051aada0a706e6f128746cfd6 to your computer and use it in GitHub Desktop.

Select an option

Save matthewnitschke/4f4896e051aada0a706e6f128746cfd6 to your computer and use it in GitHub Desktop.
ko.bindingHandlers.holdClick = {
init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var timeoutId = 0;
var option = valueAccessor() || {};
$(element).mousedown(function () {
timeoutId = setTimeout(option, 1000);
}).bind('mouseup mouseleave', function () {
clearTimeout(timeoutId);
});
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment