xxxxxxxxxx
/*script example_template is where you determine the html of the template */
/*but you actually put the template's content into a "normal" div, and this normal div is your $el*/
<body>
<div id="example_container"></div>
<script type="text/template" id="example_template">
<div><%=test %> </div>
</script>
<script type="text/javascript">
var ViewDemo = Backbone.View.extend({
initialize: function()
{
this.render();
},
template: _.template($("#example_template").html()),
render: function()
{
this.$el.html(this.template({test: "A solution"}))
}
})
var vardemo = new ViewDemo({el: $("#example_container")});
vardemo.render();