Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is not the best example.

You actually don't need to hardcode the html in the javascript. You can use a template system that is already included in backbone, or you can preform a request to the server,

I prefer the first approach.



Backbone has built in support for templating. All you have to do is tell your View object what template it needs to render and you're on your way. Obviously, you can use whatever you are comfortable with: mustache, underscore, jTemplates etc.


Or you can hardcode them using CoffeeScript's heredoc syntax.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: