Skip to content

Instantly share code, notes, and snippets.

@tvpmb
Created March 2, 2012 22:16
Show Gist options
  • Save tvpmb/1961807 to your computer and use it in GitHub Desktop.
Save tvpmb/1961807 to your computer and use it in GitHub Desktop.
Rendering a model in Backbone??
render: function(layout) {
var view = layout(this);
var themeId = this.options.themeId;
/* THIS WORKS, BUT WHY DO I NEED TO LOOP THE COLLECTION?!?! */
this.collection.each(function(theme) {
if (theme.id == themeId) {
console.log('theme: ', theme);
view.insert(new ThemeEditor.Views.PreviewContent({
model: theme
}));
}
});
/* THIS DOESN'T WORK */
var theme = this.collection.get(themeId);
view.insert(new ThemeEditor.Views.PreviewContent({
model: this.collection.get(themeId)
}));
return view.render();
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment