ICanHaz template not rendering

439 views Asked by At

I'm just started using backbone.js and ICanHaz.js for templating. But template is not getting rendered.

var MovieView = Backbone.View.extend({

    render : function() {
        this.model.movies.each(function(mov) {
            console.log("In view " + mov.get('title') + " " + mov.get('format') + " " + mov.get('rating'));
        });

         var da = JSON.parse(JSON.stringify(this.model.toJSON()));
         console.log("Moviedata " + da);
         var movList = ich.movies_tmpl(da);
        $('#movieList').append(movList);  
        return this;
    }

});

console log prints the movie data. But not in browser. \n

And in my html,

<script id="movies_tmpl" type="text/html">

          <li id="movie_{{ cid }}">
            <p>Title : {{ title }}</p>
            <p>Format : {{ format }}</p>
            <p>Rating : {{ rating }}</p>
          </li>
</script>

<h1>MovieApp</h1>
<a href="#movies/add">Add New Movie</a>
<ul id="movieList"></ul>  

TIA, Arun

1

There are 1 answers

0
Vik On

Try the following:

{{#movies}}

Title : {{ title }}

Format : {{ format }}

Rating : {{ rating }}

{{/movies}}

and maybe

 var da = JSON.parse(this.model.toJSON());