I have a problem with a backbone.js namespacing app demo, i’m trying to display a simple list of element stored locally, when i call the app the console retrieves this error
App.model.club is not a constructor
the portionof code is in the router secion;
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'}));
},
the error accoured at the fifth line in the above partion code.
this is the namespace file 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();
}
}
an this is the module file:
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');
}
});
You forgot à comma after ‘id’: 1