var events = ['tap', 'doubletap', 'hold', 'rotate',
'drag', 'dragstart', 'dragend', 'dragleft', 'dragright', 'dragup',
'dragdown', 'transform', 'transformstart',
'transformend', 'swipe', 'swipeleft', 'swiperight',
'swipeup', 'swipedown', 'pinch', 'pinchin', 'pinchout'];
ko.utils.arrayForEach(events, function (eventName) {
ko.bindingHandlers[eventName] = {
update: function (element, valueAccessor) {
// var BindingContext = valueAccessor()[0];
var EventToFire = valueAccessor()[0];
var options = {
dragLockToAxis: true,
dragBlockHorizontal: true
};
var hammerTime = new Hammer(element, options);
hammerTime.on(eventName, function (ev) {
//Fire the event with the item it was bound to.
EventToFire();
});
}
};
});
<table width="100%" border="0" cellspacing="0" cellpadding="0" data-bind="swipeleft: [SwipeLeft], swiperight: [SwipeRight]">
<tr>
<td>
<input type="text" data-bind="value: customer.name, valueUpdate: 'afterkeydown'">
</td>
<td>
<input type="text" data-bind="value: customer.code, valueUpdate: 'afterkeydown'">
</td>
<td>
<input type="text" data-bind="value: customer.description, valueUpdate: 'afterkeydown'" style="width: 295px">
</td>
</tr>
</table>