knockout.jsbarcodebindinghandlers

Knockout binding works when typed, but not when bar-coded


I have a custom Binding that works on Keyup and when users manually type in data the valueAccessor().call works just fine and enters the desired next function. However, when we barcode the same data, and send the same return key, (i have checked that the last keyCode being send is 13 with both methods) the valueAccessor doesn't make it to the next function and drops out.

I suspect this could have something to do with the speed at which the barcoded data is entered into the field and the subsequent "enter" key. Would slowing down the rate the barcoded characters are entered help? If so, what method do you suggest?

ko.bindingHandlers.enterKey = {
init: function (element, valueAccessor, allBindings, vm) {
    ko.utils.registerEventHandler(element, "keyup", function (event)
    {
        if (event.keyCode === 13)  {
            ko.utils.triggerEvent(element, "change");
            valueAccessor().call(vm, vm); 

        }

        return true;
     }
    );
}

Solution

  • thanks for the help on this. It turns out there was a misnamed variable in the VM.