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

showAllMessages fix isModified access #269

Closed
zewa666 opened this issue Apr 19, 2013 · 2 comments · Fixed by #495
Closed

showAllMessages fix isModified access #269

zewa666 opened this issue Apr 19, 2013 · 2 comments · Fixed by #495

Comments

@zewa666
Copy link

zewa666 commented Apr 19, 2013

Hello, seems like the method showAllMessages, while trying to iterate over all validatables contains some objects not implementing isModified, which throws an undefined exception.

Dunno where these other objects come from, so my fix proposal would be to simply test against undefined.
E.g.

result.showAllMessages = function (show) { // thanks @heliosPortal
                    if (show === undefined) {//default to true
                        show = true;
                    }

                    // ensure we have latest changes
                    result();
                    ko.utils.arrayForEach(validatables(), function (observable) {
                        if(observable.isModified !== undefined)   // FIXES THE PROBLEM
                            observable.isModified(show);
                    });
                };
@sagasu
Copy link

sagasu commented Oct 22, 2014

Hi,

I had similar problem:
observable.isModified was resolved to either undefined or to true value. Due to that the code was failing. I ended up with a following code:

ko.utils.arrayForEach(validatables(), function (observable) {
    // for some reasons sometimes: observable.isModified = true
    // and code is trying to execute: true(show)
    // guard below is stopping this from happening. This is a knockout issue.
    if (!!observable && typeof (observable.isModified) == "function") {
        observable.isModified(show);
    }
});

@crissdev
Copy link
Member

@sagasu It would be great if you could provide information about your view model. It will help a lot in correcting the problem. We can't just put some if statements without knowing the root cause.

crissdev added a commit that referenced this issue Jan 7, 2015
This commit also adds an internal method to update the state for the validation group.
This method is not intended to be used directly but to provide a way to update the
group until a better API will be implemented.

Closes #442
Closes #269
Closes #209
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants