summaryrefslogtreecommitdiffstats
path: root/examples/nodejs-mongodb-mongoose-restify/app/js/router/MainRouter.js
blob: c48939a28863b2aacfd58bc28f547f9e2e1c5ac9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

define([
  'jquery',
  'underscore',
  'backbone',
  'views/MainView', 
  'views/cabin/CabinView'
], function ($, _, Backbone, MainView, CabinView) {
  
  var MainRouter = Backbone.Router.extend({
    routes: {
      '*actions': 'defaultAction',
      'messages': 'showMessageAboutMongo', // All urls will trigger this route
      'about': 'showAbout' 
    }
  });

  var initialize = function(){
		
    //var vent = _.extend({}, Backbone.Events);
    var router = new MainRouter();

    console.log("MainRouter / initialize");

		router.on('route:defaultAction', function (actions) {

        var mainView = new MainView();
        mainView.render();

        var cabinView = new CabinView();
        cabinView.render();

        console.log("default route");
        
		});

    router.on('route:showMessageAboutMongo', function () {

      console.log("display helpful message about setting up mongo");
        
    });

    router.on('route:showAbout', function () {

      console.log("display about");
        
    });

    Backbone.history.start();
    
  };
  return {
    initialize: initialize
  };
});