Knockout Validation on Breeze.js entities
Asked Answered
T

1

0

I'm trying to get Knockout Validation running on my Breeze.js entities but not having much luck.

So currently I'm just trying to get a very basic test working to confirm the approach should work but am stumped as to why this is not even working. Essentially I have something like the following running when the user edits one of my entities in an attempt to register knockout validation on the resulting entity from breeze:

dataService.getEntity(selectedRowId())
                .then(function(result) {
                    currentEntity(result.entity);
                    var ent = currentEntity();
                    ent.TestField.extend({ required: true });
                });

And then in the view the field is bound:

<input type="text" data-bind="value: currentEntity().TestField" />

But this is not working. I thought it might be because all the fields on the entity are dependantObservables, but created a test computed field and knockout validation seems to work fine on it (provided I give it a read and write method)

Can anybody suggest what I might be missing or a better way to do this sort of thing?

(PS: I'm actually attempting something like the approach from Julián Yuste here:

knockout validation using breeze utility?

but not having much luck so I'm trying to take it back to some basics)

Topless answered 1/4, 2013 at 0:14 Comment(0)
G
1

You can get a better and updated example here:

Mark fields not valid as red with knockout/durandal

Take a look and tell me if that helps.

Gangling answered 2/4, 2013 at 5:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.