javascript - Error in render backbone by handlebars:Uncaught TypeError: Cannot read property 'Object' of undefined -


i have fetched collection , used function tojson() , result this:

object {results: array[4]};

so passing object handlebars compare error:

uncaught typeerror: cannot read property 'object' of undefined.

var wrapper; var homeview = backbone.view.extend({      template: handlebars.compile(template),      events: {      },      initialize: function () {          console.log("inhomeview");          var amici = new usercollection();         amici.fetch({             success: function () {                 amici.each(function (object) {                      console.log(object.tojson());                     wrapper = object.tojson();                  });             },             error: function (amici, error) {                 // collection not retrieved.             }         });          this.render();      },      render: function () {          var context = wrapper;         var html = this.template(context);         console.log(html);          $('#pagina').html(this.$el.html(html));      }  });  return homeview;  }); 

and template this:

<section id="home">     <button>scream</button>     <input type="text" name="scream">     <button>mt</button>     <section class="lista">         <ul>{{#each object}}             <li>                 <a href="#user/{{objectid}}">                     <img src="{{avatar.url}}" width="69" height="69" />                      <h3>        {{username}} {{email}}</h3>                       <h4>7 m</h4>                     <h5>32 min</h5>                 </a>             </li>{{/each}}</ul>     </section> </section> 

don't call render until callback executes.

amici.fetch({             success: function () {                 amici.each(function (object) {                      console.log(object.tojson());                     wrapper = object.tojson();                     this.render();                  });             },             error: function (amici, error) {                 // collection not retrieved.             }         }); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -