Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Alternative Syntax For Backbone Simple Template


  <div id = "mydiv"></div>
   <script type="text/template" id="myTemplate">
   <%= tagline %>
   </script>
     <script type="text/javascript">  
 var mydivView = Backbone.View.extend({
el: "#mydiv",
initialize: function()
{
var viewdemo = new ViewDemo({});
this.$el.html(viewdemo.template({tagline: this.model}));
}
 });
        var ViewDemo = Backbone.View.extend({  
         tagName: "b",
        template: _.template($("#myTemplate").html()),  
  /*don't even need to render or initialize this if you plan to use this as a template*/
        });  
var mydiv = new mydivView({model: "proper way to add code"});
        </script>  
 
PREVIOUS NEXT
Tagged: #Alternative #Syntax #For #Backbone #Simple #Template
ADD COMMENT
Topic
Name
9+8 =