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

Validation settings are ignored after applyBindings() is called

Open phobos2077 opened this issue 9 years ago • 1 comments

I'm using bootstrap with bootstrap modals. I have main viewModel for page itself (applyBindings() on main content DIV element) and another viewModel for my modal window (another call to applyBindings()). If I apply bindings to modal DIV before I do the same for main page DIV, settings applied to ko.validation.init() are ignored.

BUT it does work if I do any of the following:

  • Call applyBindings() first on the modal and then on the page.
  • Instead of applyBindings() I call applyBindingsToNode() and then applyBindingsToDescendants() for modal.
  • Call ko.validation.init() before first call to applyBindings() on the page.
  • Use applyBindingsWithValidation() instead of applyBindings() for view modal where I need custom validation settings.

phobos2077 avatar Dec 01 '16 05:12 phobos2077

Ok now I understand what's actually happening. If applyBindings() is called on any element BEFORE ko.validation.init(), than these settings stop working.

phobos2077 avatar Dec 01 '16 06:12 phobos2077