Keeping models in sync with other objects such as views can be challenging, and if it is not done correctly, it can lead to messy code. In this chapter, we will explore how to deal with data synchronization to make data binding easier. But, what is data binding? Wikipedia defines data binding as:
Data binding is the process that establishes a connection between the application UI (User Interface) and business logic. If the settings and notifications are correctly set, the data reflects changes when made. It can also mean that when the UI is changed, the underlying data will reflect that change.
A common issue with model binding is how to deal with complex model structures that include other embedded objects or lists; in this chapter, we will define a strategy to deal with these scenarios. A missing feature in Backbone is two-way binding; in the next sections, we will see how to implement this without a headache.
Let's start the chapter describing how to bind model...