0

I am following this backbone tutorial and this require.js tutorial. I am trying to combine them.

When create an ItemListView, then I get an error

TypeError: singleItemView is not a function
   model: item

My code:

define([
  'jquery',
  'underscore',
  'backbone',
  // Pull in the Collection module from above
  'collections/projects',
  'collections/item',
  'models/projects'

], function($, _, Backbone, projectsCollection, singleItemView, itemViewModel){
  var projectListView = Backbone.View.extend({
    el: $("#page"),

....
....

    appendItem: function(item){
      var itemView = singleItemView({
        model: item
      });
      $('ul', this.el).append(itemView.render().el);
    }

How can I solve this problem?

1
  • don't see any return in your code Commented Sep 17, 2012 at 13:14

1 Answer 1

1

What you probably want is just:

var itemView = new singleItemView({
    model: item
});

I'm not sure what singleItemView is. collections/item hints at it being a collection while the name singleItemView hints that it is a view. Whatever it is, it looks like it is a module with a "class" definition and I'm betting all you need to do is instantiate it.

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.