Trying to output some value from View via template by using Backbone.js, but the list item is not showing on webpage, please have a look and advise what is missing. Thank you
<script type="text/template" id="myid">
<li> <%= value %> </li>
</script>
<script type="text/javascript">
(function($){
ListView = Backbone.View.extend({
tagName:'ul',
initialize:function(){
this.template = _.template($('#myid').html());
},
render:function(){
this.$el.append(this.template({value:"Joe Blogg"}));
return this;
}
});
$(document).ready(function(e) {
myListView = new ListView();
});
})(jQuery);
Please try this.
I use jQuery.js and Underscore.js and Backbone.js.
And Always Use “var”.