nytimes / backbone.stickit

Backbone data binding, model binding plugin. The real logic-less templates.
MIT License
1.64k stars 176 forks source link

Are you able to populate the model from the input at initialisation #85

Closed davetayls closed 11 years ago

davetayls commented 11 years ago

hey, I have had a look and can't see the answer to this in the code but I need to populate the model from the value of the input when I do the initial stickit() call. Is this possible?

It currently overwrites the input values with what is in the model (which is empty for me)

thanks

delambo commented 11 years ago

Sorry, stickit doesn't support that since it is not a typical Backbone/client app setup.

If you are rendering on the backend, have you thought about bootstrapping your backend models to the page?

mehcode commented 11 years ago

This is a normal thing to do in coupled client / server arrangements. This is what http://backbonejs.org/#Collection-reset is intended for. Bootstrapped models / collections can be a good thing. Stickit doesn't need any (and shouldn't have any) extra code to support it as how you bootstrap should be left up to the developer (and the preferred way is different depending on who you ask).

coderanger commented 11 years ago

Just to throw some fuel on this fire (months later), my use case in this instance is I have a blank form (in static HTML) and a blank model, but if you start typing in the form before the JS gets booted up and attaches, your input will just vanish. Is there any way to do a one-time read of values from the form to give as model defaults using the same logic as in stickit?