1

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);
      }

    });

  });
1
  • Please, add a error message with stacktrace Commented Jun 19, 2013 at 9:56

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.