0

我正在尝试在 Backbone 中创建一个基表类。对于每个子类,该行可能具有不同的外观。我想传入行的视图。我正在尝试将其添加为在子类中设置的属性,但我不断收到错误TypeError: Cannot read property '_listenerId' of undefined。这是我的父类:

  var BaseTableView = BaseView.extend({
    template: null,
    rowView: null,
    initialize: function() {
        ...
    }
  });

这是我设置行视图的子类:

  var PeopleCollectionView = BaseTableView.extend({

    initialize: function() {
      this.collection = new PeopleCollection();
      this.template = peopleTemplate;
      this.itemView = PersonView;
      BaseTableView.prototype.initialize.apply(this, arguments);
    }
  });

当我去使用超类中的 PersonView 时,我是这样使用它的:

var view = new this.rowView({
  model: item
});

那是我收到上述错误的时候TypeError: Cannot read property '_listenerId' of undefined。我该如何解决这个问题,或者即使我应该设置不同的层次结构,应该怎么做?谢谢您的帮助。

4

0 回答 0