I have a pop up with plenty of options which can be edited - this is a Backbone View. I have a model which is simple POCO that stores those options. It's quite hard to write each view event handler to update the model's corresponding values.
How do I update the model automatically when its view fields change?
Assume I have textbox Name
which corresponds to model.name
. I need to update model.name
automatically when I enter a new name in the textbox. Is it possible?
I know that this way will not be mvc, but mvvm, and maybe it's better to use knockout.js here, but I already have some code for backbone, so hope it is possible to find some workaround.
You can manage your form to model updates with Backbone Forms .
This plugin will allow you to update the model automatically when related view fields have changes.
From inside the view, you'd simply redeclare it with this. this.model = SomeOtherModel;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.