我有一个backbone.js 命名空间应用程序演示的问题,我正在尝试显示一个简单的本地存储元素列表,当我调用应用程序时,控制台会检索此错误
App.model.club is not a constructor
部分代码在路由器部分;
initialize: function () {
console.log('App.router Initialized');
App.clubCollection = new App.collection.clubs();
localStorage.clear();
App.clubCollection.create(new App.model.club({id: 1, name:'Open Baladin', category: 'Pubs'}));
App.clubCollection.create(new App.model.club({id: 2, name:'Ai marmi', category: 'Ristorante'}));
App.clubCollection.create(new App.model.club({id: 3, name:'Branca Leone', category: 'Disco'}));
},
上述分区代码第五行出现的错误。
这是命名空间文件 app.js:
window.App = {
model: {},
view: {},
collection: {},
router: {},
util: {},
data: {},
contentHolder : $('#app').find(":jqmData(role='content')"),
container:$('#app'),
init: function() {
console.log('window.App Initialized')
new App.router();
Backbone.history.start();
}
}
这是模块文件:
App.model.club = App.model.club || {}
App.model.club = Backbone.Model.extend({
defaults: {
'id' : 1
'name' : 'Open Baladin',
'category' : 'Pubs'
},
initialize: function() {
console.log('App.model.club initialized');
}
});