基本上我有一个我想重用的模型/集合。我在parse.com'https://api.parse.com/1/classes/foo'和'https://api.parse.com/1/classes/bar'上有几个不同的收藏品。
我的收藏:
define([
"app",
"models/listModel",
], function (app, ListModel) {
var ListCollection = Parse.Collection.extend({
model: ListModel,
});
return ListCollection;
});
我的模特:
define([
"app"
],
function(app) {
var ListModel = Parse.Object.extend({
className: null,
initialize: function(attrs, options) {
this.className = app.foobar ? 'foo' : 'bar';
}
});
return ListModel;
});
然后我创建了一个新的集合:
app.foobar = 'bar';
var collection = new ListCollection();
collection.fetch({
wait: true,
success: function(collection, response, error) {
console.log(collection);
}
});
这是我得到的错误:
Uncaught Error: Parse.Object.extend's first argument should be the className.
在模型中触发初始化之前抛出它。