Skip to content

Instantly share code, notes, and snippets.

@vjiawon
vjiawon / gist:3143813
Created July 19, 2012 13:12
Knockout click bindings to disable a button until the function it calls resolves the returned promise
(function (ko) {
"use strict";
ko.bindingHandlers.customClickHandler = {
init: function (elem, valAccessor, allBindingsAccessor, data) {
var targetFunction = valAccessor(),
cmd = function (vm, event) {
var promise;
if (targetFunction.canExecute()) {
targetFunction.canExecute(false);