Created
August 14, 2012 09:19
-
-
Save ralphcrisostomo/3347753 to your computer and use it in GitHub Desktop.
using handlebars with backbone block collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reference: | |
// http://stackoverflow.com/questions/7344982/questions-on-backbone-js-with-handlebars-js | |
var ArticleListView = Backbone.View.extend({ | |
el: $('#main'), | |
render: function(){ | |
var js = this.collection.toJSON(); | |
var template = Handlebars.compile($("#some-template").html()); | |
$(this.el).html(template({articles: js})); | |
return this; | |
} | |
}); | |
// Sample Handlebars Template | |
/** | |
<script id="some-template" type="text/x-handlebars-template"> | |
{{#each articles}} | |
{{this.title}} | |
{{/each}} | |
</script> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment