Knockout-Contrib / Knockout-Contrib/Knockout-Validation

Validation settings are ignored after applyBindings() is called

Open
#638 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1k
Forks
366
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with separate modal and page view models, calling applyBindings() in the reported orders and applying ko.validation.init() at different points. Start by tracing the applyBindings and validation initialization entry points; done means custom validation settings remain effective regardless of which view is bound first.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.