View Rendering
<!DOCTYPE HTML><HTML><Head> <MetaCharSet= "UTF-8"> <title>Document</title> <Scriptsrc= "Jquery-1.9.1.js"></Script> <Scriptsrc= "Underscore.js"></Script> <Scriptsrc= "Backbone.js"></Script></Head><Body> <DivID= "Search_container"></Div> <Scripttype= "Text/template"ID= "Search_template"> <label><%=Search_label%></label> <input type="text"ID="Search_input" /> <input type="Button"ID="Search_button"value="Search" /> </Script><Script>(function ($) { //Add the following test code here varSearchview=Backbone.View.extend ({initialize:function(){},//InitializeRender:function(content) {//Rendering Methods varTemplate=_.template ($ ('#search_template'). HTML (), content);//Template Parsing $( This. EL). HTML (template);//Add the parsed code fragment to the El } }); varSearchview=NewSearchview ({//Instantiate a Viewel:$ ('#search_container')//specify El elements (each view will have an El attribute, and if not we specify, backbone will automatically generate a DIV element) }); Searchview.render ({search_label:"Search Rendering"});//invoking the rendering method of the view}) (jQuery);</Script></Body></HTML>
Backbone.js Introductory Tutorial Second Edition notes (3)