How to connect changes some field in model to reflect on view ?
I have model which holds font-weight and I have that model in view, but how to connect changes of font-weight filed in model to reflect on el from view ?
How to connect changes some field in model to reflect on view ? I
Share
There are several approachs that can be applied here on depending that how much delicate you want to be.
1. re-render the whole View any time the Model change
2. be more precise and only re-render what is needed
This needs the company of minimal render methods that modify the DOM as a surgeon:
3. use subviews for every part of the Model
I’m not offering any example for this approach because the implementation can be more complex. Just think that your actual
Viewis instantiating severalSubViews, one for thetitle, other for thebody, and so on. Each one with its ownrenderand binding the changes in its concreteModelattribute andre-renderwhen the attribute changes.You can check working jsFiddle code for the approachs 1. and 2.