Accepted answer

Complementing to answers and comments of others, I get this solution:

var MyChartView = Backbone.View.extend({
    template: _.template($('#myChart-template').html()),
    render: function(){

        var data = ...
        var options = ...

        var ctx = $('#myChart', this,el)[0].getContext("2d");
        var myLineChart = new Chart(ctx).Line(data, options);

Hope this help you.


Since document.getElementById("myChart"), is unable to find the canvas/myChart as it is within the script tag.

Try this,

var ctx = $($('#myChart-template').html()).children('#myChart').get(0).getContext("2d");

Hope this solves the issue. :)

Related Query

More Query from same tag