The error points to the backbone.js:219 library. The error is thrown in my main.js file in the require(['app'], function.
main.js file:
require.config({
baseUrl: 'scripts',
paths: {
app: '../app',
jquery: 'jquery',
underscore: 'underscore',
backbone: 'backbone',
router: '../router'
},
shim: {
backbone: {
deps: ['jquery','underscore'],
exports: 'Backbone'
}
}
});
require(['app'], function (App) {
App.initialize();
});
My app.js file:
define([
'jquery',
'underscore',
'backbone',
'router' // Request router.js
], function($, _, Backbone, Router){
var initialize = function(){
// Pass in our Router module and call it's initialize function
Router.initialize();
};
return {
initialize: initialize
};
});
My router.js file:
require(['jquery', 'underscore', 'backbone'], function ($, _, Backbone) {
'use strict';
// Router
var AppRouter = Backbone.Router.extend({
routes:{
"":"list",
"wines/:id":"wineDetails"
},
list:function () {
this.wineList = new WineCollection();
this.wineListView = new WineListView({model:this.wineList});
this.wineList.fetch();
$('#sidebar').html(this.wineListView.render().el);
},
wineDetails:function (id) {
this.wine = this.wineList.get(id);
this.wineView = new WineView({model:this.wine});
$('#content').html(this.wineView.render().el);
}
});
return AppRouter;
});
This question seems to similar to this one, but none of the suggestions worked for me.
Aucun commentaire:
Enregistrer un commentaire