javascript - Does it make sense to initialize models from the DOM in backbone.js? -


backbone.js relies on restful applications initialize models, progressive enhancement? data in dom (or of it), should models still make calls the restful interface though html elements exist? there library design might better suited case?

you should not use dom element initialize model backend data. have nice infrastructure backbone not this. when rely on dom need change javascript whenever dom structure change due design exemple.

also not rely on backbone view create model. must go other way around, model dictate views on page.

just add script element , create js objects directly in there. can initialize collections, single models, etc.

you can same templates or dom ui building blocks:

<script type="text/js-template">   <!-- template realy elements or using js templating engine _.template--> </script> 

load page , have app play locally.


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -