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

Error message "isValid is not defined" after upgrade to Knockout.Validation 2.0.3 #661

Open
verheyenkoen opened this issue Aug 2, 2018 · 0 comments

Comments

@verheyenkoen
Copy link

verheyenkoen commented Aug 2, 2018

I just upgraded Knockout.Validation to the latest release (as I need validation on the new textInput binding) and on this existing binding:

<form data-bind="with: new">
    ....
    <button data-bind="enable: isValid, click: $parent.submit">Submit</button> // or isValid()
</form>

... the following error occurs:

Message: Unable to process binding "enable: function(){return isValid() }"
Message: isValid is not defined
    at enable (eval at createBindingsStringEvaluator (knockout-3.4.2.debug.js:2992), <anonymous>:3:59)
    at update (knockout-3.4.2.debug.js:4211)
    at ko.dependentObservable.disposeWhenNodeIsRemoved (knockout-3.4.2.debug.js:3383)
    at Function.evaluateImmediate_CallReadThenEndDependencyDetection (knockout-3.4.2.debug.js:2183)
    at Function.evaluateImmediate_CallReadWithDependencyDetection (knockout-3.4.2.debug.js:2150)
    at Function.evaluateImmediate (knockout-3.4.2.debug.js:2111)
    at Object.ko.computed.ko.dependentObservable (knockout-3.4.2.debug.js:1964)
    at knockout-3.4.2.debug.js:3381
    at Object.arrayForEach (knockout-3.4.2.debug.js:159)
    at applyBindingsToNodeInternal (knockout-3.4.2.debug.js:3353)

Basically I do this (heavily reduced code):

model.new = new MyModel();
ko.validatedObservable(model.new);
ko.applyBindings(model);

I also tried it like this, but the same error occurs:

model.new = ko.validatedObservable(new MyModel());
ko.applyBindings(model);

The strange thing is that if I change the button binding as follows, the error is gone, but the button remains disabled even if my model becomes valid:

<button data-bind="enable: $parent.new.isValid, click: submit">Submit</button>

I also checked in the console and executing model.new.isValid() there throws the error "Uncaught TypeError: model.new.isValid is not a function".

I guess something must have changed in either Knockout or Knockout validation but I can't find what could be wrong here.

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

1 participant