I seem to encounter a brick wall with backbone.js / underscore.js when I try to import a template that looks like this:
<script type="text/template" id="overview_template"> <div> Sample text </div> </script>
Error:
Uncaught TypeError: Object
The code causing the error is this.el.html(template);
in the following:
var OverviewView = Backbone.View.extend({ el: $('#overview_container'), initialize: function() { this.render(); }, render: function() { var template = _.template( $("#overview_template").html(), {} ); this.el.html(template); }, defaults: { tip_of_the_day: 'open', news: 'open', recent_presentations: 'open' }, events: { "click .overview_subsection_header": "toggleSubsection" }, toggleSubsection: function (event) { $(this).parent().find('.overview_subsection_content').toggle(); } }); var overview_view = new OverviewView();
I'm not sure what causes this, but it drove me crazy.
source share