Created
August 29, 2012 21:12
-
-
Save tvpmb/3519054 to your computer and use it in GitHub Desktop.
Simple Backbone Template
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
<div id="search_container"></div> | |
<script type="text/javascript"> | |
SearchView = Backbone.View.extend({ | |
initialize: function(){ | |
this.render(); | |
}, | |
render: function(){ | |
// Compile the template using underscore | |
var template = _.template( $("#search_template").html(), {} ); | |
// Load the compiled HTML into the Backbone "el" | |
this.el.html( template ); | |
} | |
}); | |
var search_view = new SearchView({ el: $("#search_container") }); | |
</script> | |
<script type="text/template" id="search_template"> | |
<label>Search</label> | |
<input type="text" id="search_input" /> | |
<input type="button" id="search_button" value="Search" /> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment