|Custom valueUpdate event||Todd Sharp||2/23/12 6:16 AM|
I'm pretty new to Knockout - coming from the Flex world where binding
is pretty mature so I've got some questions as to how binding works in
the JS/Knockout world.
Is there a way to create a custom event for valueUpdate so that I can
defer updating my model until an object has been validated/saved?
Ultimately it'd be pretty cool to be able to do something like this:
<input type="text" data-bind="value: name, valueUpdate:
I thought I'd work around this limitation by specifying no (or a null)
valueUpdate and manually calling notifySubscribers() but it appears
that valueUpdate fires onBlur by default (even if I pass null).
Am I off in thinking that this would be a valid use case? I'm just
trying to consider a 'Cancel' or 'Reset' situation on an edit form
where I don't want to leave my model dirty when a user decides not to
|Re: Custom valueUpdate event||Michael Best||2/23/12 7:09 AM|
I think the way to do validation is to use a writable computed
observable to filter writes to the value. You could do this with an
extender that creates and returns the wrapping *computed*.