I am making a notification system and am getting the following error:
Uncaught TypeError: _.template(...).html is not a function
Here is the code:
<script type="text/x-template" id="notifications-template">
<ul>
<%
_.each(notifications, function(notification{
if( notification.type == 1){ %>
<li><% = notification.gig.artist.name %>has canceled the gig at <% = notifications.gig.venue at <% =notifications.gig.datetime. %></li>
<%
}
}))
%>
</ul>
</script>
<script>
$(document).ready(function () {
$.getJSON("/api/notifications", function (notifications) {
$(".js-notifications-count")
.text(notifications.length)
.removeClass("hide")
.addClass("animated bounceInDown");
$(".notifications").popover({
html: true,
title: "Notifications",
content: function () {
var compiled = _.template("#notifications-template").html();
return compiled({ notifications: notifications });
},
placement: "bottom"
});
});
});
</script>
Update
The '$' selector within _.template($("#notificação").html()
was missing
But now I get an error in underscore.js
Uncaught SyntaxError: Unexpected token {