Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

JMVC Model Validation Queries

$
0
0
(JMVC not Can!)

I've been reading through the JMVC Model Validation docs and have a few questions which I can't seem to obtain definitive answers for. I hope someone can help!

Why is model validation placed in the static init() method? My understanding of this is because init() is called every time you try and save the model, hence validation kicks in. Is that correct? What if I wanted to have real-time validation on a form i.e. the validation happens on keyup/blur rather than when the form is submitted? Is it possible to structure the validation so it can be called legitimately without saving to the server?

Also, does model validation trickle down through associated models? E.g. validation on the parent model triggers validation on associated models?

Does anyone have any other examples of model validation apart from the Birthday example?

Thinking back I remember validation being called when setting an attribute with model.attr('foo', 'bar', success, error) - I imagine I can invoke validation without saving the model in the same way this attr validation is called?

Many thanks all!

Viewing all articles
Browse latest Browse all 3491

Trending Articles