获取Backbone集合时出错:必须指定“url”属性或函数

时间:2012-09-26 10:49:19

标签: javascript backbone.js

我尝试获取一个简单的Backbone Collection,但是我收到以下错误。

  

必须指定“url”属性或函数

var Collection = Backbone.Collection.extend({url: '/path/toCollection'});
var collection = new Collection([]);
app.vent.bindTo('applicationDidBecomeActive', collection.fetch);
app.vent.trigger('applicationDidBecomeActive');
//Error: A "url" property or function must be specified

1 个答案:

答案 0 :(得分:1)

您是否需要绑定'this'参数?

app.vent.bindTo('applicationDidBecomeActive', collection.fetch, collection);