我正在尝试监听 onChange 事件以收集并收到错误:
Uncaught TypeError: listSongs.on is not a function
这是我的代码:
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) {
关于javascript - onchange 集合出现错误而不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32738015/