Knockout-Validation icon indicating copy to clipboard operation
Knockout-Validation copied to clipboard

How can I decorate different input element?

Open hfirst opened this issue 9 years ago • 1 comments

I am using Kendo and their combobox is a combination of different divs and spans, so the built in mechanism to decorate the input element (change the border color) doesn't work since that's not actually the visible part.

I did find the trick below and it does work, problem is, it ends up immediately highlighting the required combos in red as soon as the form loads when creating new records.

How can I hook the default mechanism so that I can decorate the correct element AND not also have errors be highlighted immediately on form load?

Trick to highlight input element:

ko.bindingHandlers.parentvalElement = { update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { if (element.nodeName!=="SELECT") return; var valueIsValid = valueAccessor().isValid(); if(!valueIsValid ) { $(element.parentElement.children[0]).addClass("FieldError"); } else { $(element.parentElement.children[0]).removeClass("FieldError"); } } };

hfirst avatar May 18 '15 01:05 hfirst

+1

this might be of help: http://dojo.telerik.com/eboWu

crashnick16 avatar Sep 17 '15 14:09 crashnick16