Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Backbone.Controller undefined even when Backbone is defined?

I'm trying to add controller to my Todo list app. Here's the code.

$(function(){
alert(Backbone); // => [object]
alert(Backbone.Controller); // => undefined
TodoList.Controllers.Todos = Backbone.Controller.extend({
routes: {
    "documents/:id": "edit",
    "": "index",
    "new": "newDoc"
},

edit: function(id){
    var todo = new Todo({id:id});   
    todo.fetch({
        success:function(model,resp){
            new App.Views.Edit({model:todo});
        },
        error: function(){
            new Error({message: "Couldn't find the todo item."});
            window.location.hash = '#';
        }
    });
},

index: function(){
    window.App = new TodoList.Views.AppView
}

});
});

As mentioned in the comment, when I alert(Backbone), [object] is returned, while Backbone.Controller returns undefined and I can't figure out why. This is stopping the whole app to work.

like image 878
Apoorv Parijat Avatar asked May 07 '26 14:05

Apoorv Parijat


1 Answers

It's been replaced with Backbone Router: http://backbonetutorials.com/what-is-a-router/

like image 91
reach4thelasers Avatar answered May 10 '26 06:05

reach4thelasers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!