title: Backbone.js Uncaught TypeError
body: <p>I have written the flowing backbone.js program :</p>
  
  <pre><code>&lt;script&gt;
  
          var PostModel = Backbone.Model.extend();
          var PostView = Backbone.View.extend({
             template: _.template($('#posttemplate').html()),
             intialize: function() {
                console.log("intializing view");
             },
             render: function() {
                console.log("rendering..");
                var htmloutput = this.template(this.model.toJSON());
                $('#postcontainer').html(htmloutput);
                return this;
             }
          });         
  
         $(document).ready(function() {
             var postmodel = new PostModel({title: "hello"});
             var postview = new PostView({model: postmodel});
             postview.render();
          });
  
  
      &lt;/script type="text/javascript"&gt;
  
  
  
  &lt;script type="text/template" id="posttemplate"&gt;
          &lt;div&gt; Title: &lt;%= title %&gt; , post: &lt;%= post %&gt; &lt;/div&gt;
  &lt;/script&gt;
  
  &lt;div class="container" id="postcontainer"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>when i run the code i get the following error:</p>
  
  <p>Uncaught TypeError: Cannot read property 'replace' of undefined </p>
  
  <p>but it works perfectly fine when i put 
  template = _.template($('#posttemplate').html()); into the render function.</p>