Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 2011-01-28-what-is-a-view.md #118

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
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