Two way data binding between form and ember object/data/model

Hi,

I’m a new learner and struggling to understand some basic concepts, any help would be greatly appreciated.

I want to know how to bind form elements to ember objects. Suppose my route is bound to a model object and I want it to be bind to input fields of the login form. From my understanding all input values will be bounded automatically to corresponding controller but if I want to use the model of the router to be bounded to form elements, how do I do this? Ideally when someone types in anything to input fields,they should automatically update the model without using any computed property or observers. I know it’s possible, most probably missing something.

Also how do I do form validation? I want to validated a field when someone finish typing instead of round tripping the whole form submission process.

Many thanks,

Mahbub

1 Like

I can’t wait to see the answers to this because I have some of these questions too. What prompted me to reply was the thought that you need to do validation on the server side too, when submitting data, in case your user turns off JavaScript to defeat your validation. Then I realized that we are talking about an SPA written in JavaScript. No way to turn it off and still have the page submit. Although there are other ways to hack your REST web service backing your application that will require you to do validation on the server as well as on the client.

I also got that you didn’t want to round-trip your validation, and implement it client side. I also want to implement client side validation before storing values in HTML5 local storage.

check the simple form validation that I made in jsbin

I hope it helps

1 Like

Spot on … this is what I was looking for. Thanks a lot.

Now I’ll try replace the model with Ember Data and see who it behave