Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions _posts/2011-01-28-what-is-a-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,14 @@ _Using template variables_
this.render();
},
render: function(){
//Pass variables in using Underscore.js Template
var variables = { search_label: "My Search" };
// Compile the template using underscore
var template = _.template( $("#search_template").html(), variables );
// Load the compiled HTML into the Backbone "el"
this.$el.html( template );
// Set an object containing our variable(s)
var variables = { search_label: "My Search"};
// Reference the template partial using underscore
var template = _.template( $("#search_template").html() );
// Pass variables into the Underscores.js template and compile it
var result = template(variables);
// Load the compiled HTML into the Backbone "el"
this.$el.html( result );
},
events: {
"click input[type=button]": "doSearch"
Expand Down