Invoking valueAccessor
just gives you access to the object that was set in the binding. Since it is a function and you want to invoke it, you have to invoke the result of calling valueAccessor
.
ko.bindingHandlers.tap = {
'init': function(element, valueAccessor) {
var tap = new Hammer(element);
var value = valueAccessor(); // get the value (the function)
tap.ontap = function(ev){
//call the method provided in HTML, in this case doSomething();
value(); // call the function
};
}
}