![]() ![]() We need to remove the tag from the template because each view instance for each model will generate the tag for us (using the `tagName` attribute in the above code). Our HTML template for each model is almost the same. This happens because we have one view instance for every model instance, and each view holds a direct reference to that model. The primary advantage that we get from using a View per Model is knowing exactly which model instance we are working with, when an event fires. It only moves the implementation for each individual model down to a View for that Model. This does not remove the need to have a View object that iterates the collection and populates the list, though. That is, each model in our collection has it’s own view object to render that mode’s data. The other approach that we can take, to know which of the models we are trying to work with when we click an HTML element, is to have one View object per Model rendered. There is another way to handle this scenario, though it has it’s own cost.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |