I’ve been following the cloudedit tutorial http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/ for adding backbone to my rails app, but I’m using rails 3.1.3 rather than 3.0.
I keep getting the following errors
Uncaught TypeError: Cannot call method 'extend' of undefined application.js:7Uncaught TypeError: undefined is not a function
I believe the error is caused by the following code
var App = {
Views: {},
Controllers: {},
Collections: {},
init: function() {
new App.Controllers.Recipes();
Backbone.history.start();
}
};
which is pretty much right from the tutorial.
I currently have this code in
assets/javascripts/application.js
file, underneath the section where I include the directories, and I call
$(function(){
App.init();
});
in my application.html.erb file.
the line which the error is actually referring to is
App.Controllers.Recipes = Backbone.Controller.extend(
I’ve tried moving the var App around to different files, but i can’t seem to get it to work.
Am I understanding that error correctly? Is there something else I may be missing?
Are you using a version of Backbone >=
0.5.0if so there is noControllerobject anymore. It’s been renamed toRouter.