Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

knockout.validation module has stopped working in 3.5.0-rc #2420

Closed
azaslonov opened this issue Oct 15, 2018 · 4 comments
Closed

knockout.validation module has stopped working in 3.5.0-rc #2420

azaslonov opened this issue Oct 15, 2018 · 4 comments

Comments

@azaslonov
Copy link

Hi guys, knockout validation module has stopped working in 3.5.0-rc, saying this:

knockout-latest.js:84 Uncaught Error: ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node
    at a.qc (knockout-latest.js:84)
    at Object.ko.applyBindings (knockout.validation.js:1472)
    at HTMLDocument.<anonymous> (startup.designtime.ts:50)

Simple repro: https://jsfiddle.net/azaslonov/4z62mw1r/

Considering they didn't release since 2015, there is probably something got broken in KO itself.
https://github.com/Knockout-Contrib/Knockout-Validation/releases

Can you guys please have a look?

@fastfasterfastest
Copy link

fastfasterfastest commented Oct 15, 2018

See #2388 - to summarize, prior to 3.5 it was unspecified what it meant by passing a non-DOM-node value as a 2nd parameter to ko.applyBindings; in 3.5 if you pass a 2nd parameter it needs to be a DOM node.

Knockout Validation overrides ko.applyBindings and always passes a 2nd parameter to the original ko.applyBindings. In your sample, knockout therefore throws an error because the value of the parameter that gets passed to the original ko.applyBindings is undefined, which is not a DOM node.

Probably, the easiest way if you use Knockout Validation is to always passing a 2nd parameter explicitly with the value document.body. In your sample, change ko.applyBindings() to ko.applyBindings(undefined, document.body)

@azaslonov
Copy link
Author

Thank you, I think I can live with this for now.

@fastfasterfastest
Copy link

Alternatively, patch knockout-validation and change the call origApplyBindings(viewModel, rootNode) to origApplyBindings.apply(this, arguments).
If you are using its ko.applyBindingsWithValidation you probably need to update it as well.

@mbest
Copy link
Member

mbest commented Feb 28, 2021

Issue was fixed in knockout-validation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants