I am currently using the validation plugin from https://github.com/ericmbarnard/Knockout-Validation and it is working nicely on plain value fields such as input boxes, but I can not get any validation messages to appear on typeahead fields.
The observable that the typeahead is assigned to has a required validation rule assigned to it, and the plugin can validate it, e.g. when it is blank calling isValid() returns false, but the validation message is not showing.
My typeahead custom binding is as follows:
ko.bindingHandlers.typeahead =
init: (element, valueAccessor) ->
binding = this
elem = $(element)
value = valueAccessor()
elem.typeahead(
source: ->
ko.utils.unwrapObservable(value.source)
onselect: (val) ->
value.target val
)
elem.change ->
value.target elem.val()
update: (element, valueAccessor) ->
elem = $(element)
value = valueAccessor()
elem.val value.target()
and is used like:
<input type="text" data-provide="typeahead" data-items="4" data-bind="typeahead: { target: selectedValue, source: sourceValues}" />
One post on the github issues suggests pasting in ko.bindingHandlers.validationCore.init(element, valueAccessor)
at the end of the init section of the binding, but this has not seemed to help anything