-_-#【Backbone】View
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <link rel="stylesheet" href="../../app-min.css"> <script src="../../jquery/jquery-1.10.2.js"></script> <script src="../underscore.js"></script> <script src="../backbone.js"></script> <script> var SearchView = Backbone.View.extend({ initialize: function() { console.log('init a SearchView') }, render: function(context) { var template = _.template($('#search_template').html(), context) $(this.el).html(template) }, events: { 'click input[type=button]': 'doSearch' }, doSearch: function(event) { console.log('search for ' + $('#search_input').val()) } }) var searchView = new SearchView({el: $('#search_container')}) searchView.render({search_label: '搜索渲染'}) </script> <article class="content"> <pre>var SearchView = Backbone.View.extend({ initialize: function() { console.log('init a SearchView') }, render: function(context) { var template = _.template($('#search_template').html(), context) $(this.el).html(template) }, events: { 'click input[type=button]': 'doSearch' }, doSearch: function(event) { console.log('search for ' + $('#search_input').val()) } }) var searchView = new SearchView({el: $('#search_container')}) searchView.render({search_label: '搜索渲染'})</pre> </article> </body> </html>