Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am new to django.

From my findings, I tried this way, but didn't work.

<script type="text/javascript" >
    var data = {{json}}
</script>

I am trying to use data table from this website, http://www.datatables.net/manual/data.

<script type="text/javascript" class="init">
var temp = '{{campaignList|escapejs}}';    // should be a list, but becomes a string
alert(typeof temp)
$(document).ready( function () {
    $('#campaigns').DataTable({
        data: temp,
        columns: [
          { data: 'id' },
          { data: 'name' },
          { data: 'date' },
        ]
      });
} );
</script>

When I check the type before passing into datatable, the type becomes string. I also tried {{campaignList|escapejs}} without quote.

Any suggestion? Thanks.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.