Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change model fields automatically when view changed in backbone.js

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.

like image 286
Ph0en1x Avatar asked Feb 15 '26 18:02

Ph0en1x


1 Answers

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.

like image 124
Marty Cortez Avatar answered Feb 18 '26 08:02

Marty Cortez