Revesiting Backbone.js View Rendering(elving.me)
elving.me
Revesiting Backbone.js View Rendering
http://elving.me/post/45836034024/revesiting-backbone-js-view-rendering
8 comments
[deleted]
I agree that putting all that logic and template vars into a template is confusing. Hard to create mocks of what the HTML should actually be structured like. Im using Jade so I can be terse and pre-compiling the templates. While in my Backbone application, I apply DOM-like rendering with Plates.js.
I'm not familiar with Backbone but isn't `model.toJSON()` unnecessarily removing useful data types (like Date) that aren't available in JSON ?
You're probably thinking of `JSON.stringify()`. `model.toJSON()` just returns a clone of the models attributes object.
So `model.toJSON()` isn't supposed to return a JSON-compatible data structure ?
It's supposed to return an object that is suitable for turning into JSON, but it won't convert any of items members. JSON.stringify relies on the toJSON functions of the members to serialize themselves.
Why is using 'model.toJSON()' overkill?
Performance isn't the only thing to consider.