我正在尝试监听onChange事件以收集并得到错误:


  未捕获的TypeError:listSongs.on不是函数


这是我的代码:

       var listSongs= {
        nextLink: "",
        collection: ListSongsCollection
      };

     render: function () {
      var view=this;
      listSongs.on("change", function(eventName) {


更新,忘记添加我的模型:

var SongModel = Backbone.Model.extend({
    defaults:{
        title: '',
        image:'',
        id:''

    }

});

var ListSongsCollection= Backbone.Collection.extend({
    model: SongModel
});

最佳答案

尝试这个:

var listSongs= {
    nextLink: "",
    collection: new ListSongsCollection()
  };

 render: function () {
  var view=this;
  listSongs.collection.on("change", function(eventName) {

10-06 04:36