Reputation: 167
I get this uncaught type error of object is not a function when trying to write a collection view. I have used the same code while doing the App but as am re doing the app with require.js, I get this error. Please help me. Here is the code :
define([
'underscore',
'backbone',
// Sub Views
'view/todo_view'
],function(
_,
Backbone,
// Sub Views
TodoView
){
return Backbone.View.extend({
el:$('#todos'),
render: function(){
this.collection.forEach(this.addOne,this);
return this;
},
addOne: function(todoIt1){
var todoView = new TodoView({
model: todoIt1
});
this.$el.append(todoView.render().el);
}
});
});
Upvotes: 1
Views: 3823
Reputation: 8293
This kind of error happens when using the operator new
with an object, and not a function. You should check if TodoView
really is a function, and not an instance of TodoView
. If that's the case, make sure you didn't misplace a new
operator in your TodoView
file.
Upvotes: 2