You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the need to place the validation message somewhere else in the dom. Additionally I want to also display validation messages for other bindings than the "value" binding. This is because I am using "knockout kendo" and that in turn does not always use the "value" binding only.
So one solution would be using the "validationMessage" binding, but that is insufficient as I cannot reuse my "messageTemplate" there.
So instead of
I created an additional binding handler
the "validationElementFor" binding replaces its owning element with the automatically created knockout validation validationElement and also takes the "messageTemplate" into account.
Here is the binding:
ko.bindingHandlers['validationElementFor'] = {
update: function (element, valueAccessor) {
var obsv = valueAccessor(),
config = utils.getConfigOptions(element), // THIS REFERENCES INTERNAL utils FUNCTION!!
val = ko.utils.unwrapObservable(obsv),
msg = null,
isModified = false,
isValid = false;
// if we're told to use a template, make sure that gets rendered
if (config.messageTemplate) {
ko.renderTemplate(config.messageTemplate, { field: valueAccessor() }, null, element, 'replaceNode');
} else {
ko.applyBindingsToNode(element, { validationMessage: valueAccessor() });
}
}
};
My problem: I cannot re-use the function utils.getConfigOptions(element) if I only add the binding in a separate javascript module and I do not want to copy loads of internal knockout validation stuff (such as the complete utils part) in order to get this working.
Could you provide me with some hint in how to do this best? Or even add this (or a similar) binding to the knockout validation library?
The text was updated successfully, but these errors were encountered:
Hi!
I have the need to place the validation message somewhere else in the dom. Additionally I want to also display validation messages for other bindings than the "value" binding. This is because I am using "knockout kendo" and that in turn does not always use the "value" binding only.
So one solution would be using the "validationMessage" binding, but that is insufficient as I cannot reuse my "messageTemplate" there.
So instead of
I created an additional binding handler
Here is the binding:
My problem: I cannot re-use the function utils.getConfigOptions(element) if I only add the binding in a separate javascript module and I do not want to copy loads of internal knockout validation stuff (such as the complete utils part) in order to get this working.
Could you provide me with some hint in how to do this best? Or even add this (or a similar) binding to the knockout validation library?
The text was updated successfully, but these errors were encountered: