pedalpete
pedalpete

Reputation: 21536

backbone.js not loading routes

I've been using backbone.js in a few projects now without issue, and I've just started a new project,but for the life of me, I cannot get the routes to load. I'm getting no errors in chrome developer tools, but I also can't get a simple alert to fire.

When I look through my code in the developer tools, my router.js file and everthing.

application.js - alerts work in this page

    render: function(){
          new MyApp.Routers.Start();
              Backbone.history.start;
          alert('started');

    }

my router.js - these alerts don't get triggered

MyApp.Routers.Start = Backbone.Router.extend({
    routes: {
        "near_me": "near_me",
        "": "index"
    },

    index: function(){
        alert('main');
    },

    near_me: function(){
        alert('map');
        var my_map = new LikeMyWine.Models.Map({
        latitude: "-34.397",
        longitude: "150.644",
        });
        new LikeMyWine.Views.NearMe({model: my_map});
    }
});

Upvotes: 0

Views: 126

Answers (1)

mpm
mpm

Reputation: 20155

 Backbone.history.start();

start is a function that actually need to be executed

i quote your code :

render: function(){
      new MyApp.Routers.Start();
          Backbone.history.start;
      alert('started');

}

Upvotes: 2

Related Questions