我正在使用RequireJS來處理所有依賴關係。嘗試使用我的集合時獲取「undefined不是函數」
因此,這裏是我的觀點:
define([
'jquery',
'underscore',
'backbone',
'bootstrap',
'collections/InstitutionsCollection'
], function($, _, Backbone, InstitutionsCollection){
var InstitutionsView = Backbone.View.extend({
render: function() {
var institutions = new InstitutionsCollection();
institutions.fetch({
success: function() {
console.log("success!");
}
});
}
});
return InstitutionsView;
});
的錯誤是在這條線拋出: var institutions = new InstitutionsCollection();
這裏是我的收藏:
define([
'jquery',
'underscore',
'backbone',
'models/InstitutionModel'
], function($, _, Backbone, InstitutionModel){
var InstitutionsCollection = Backbone.Collection.extend({
model: InstitutionModel,
url: '/institutions/'
});
return InstitutionsCollection;
});
而如果你需要它,這是我的型號:
define([
'jquery',
'underscore',
'backbone'
], function($, _, Backbone){
var InstitutionModel = Backbone.Model.extend({
});
return InstitutionModel;
});
我盯着它一會兒,我只是不知道爲什麼它會拋出這個錯誤。任何幫助是極大的讚賞。
太好了,就是這樣!我知道這會是這樣的小事,我無法弄清楚。謝謝! –