backbone.js - Undefined is not a function -
i've started learning backbone.js , tried write first app collections. here code:
console.clear(); (function($){ window.app = { models : {}, collections : {}, views : {} }; //a single estimate app.models.estimate = backbone.model.extend({}); // multiple esitmates app.collections.estimates = backbone.collection.extend({ model : app.collections.estimate }); app.views.estimates = backbone.view.extend({ tagname: 'ul', render : function(){ this.collection.each(this.addto,this); }, addto:function(estimate){ var dir = app.views.estimate({model:estimate}).render(); this.$el.append(dir.el); } }); app.views.estimate = backbone.view.extend({ tagname: 'li', render :function(){ this.$el.html(this.model.get('title')); return this; } }); var json = [{title:'abhiram', estimate:8}]; var estimates = new app.collections.estimates(json); console.log(estimates); var tasksview = new app.views.estimates({collection:estimates}); // var = tasksview.render().el; //console.log(a); })($j||jquery);
i've 3 included :
jquery first, underscore next , backbone. keep getting "undefined not function".please let me know if doing wrong.
thanks!
are sure want assign collection app.collections.estimate
model self?
// multiple esitmates app.collections.estimates = backbone.collection.extend({ model : app.collections.estimate });
Comments
Post a Comment