summaryrefslogtreecommitdiffstats
path: root/_site/examples/cross-domain/js/router.js
blob: fcd8d03d835928f7346e44f59526405a01d9360f (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
// Filename: router.js
define([
  'jquery',
  'underscore',
  'backbone',
	'vm'
], function ($, _, Backbone, Vm) {
  var AppRouter = Backbone.Router.extend({
    routes: {
      '*actions': 'defaultAction' // All urls will trigger this route
    }
  });

  var initialize = function(options){
		var appView = options.appView;
    var router = new AppRouter(options);

		router.on('route:defaultAction', function (actions) {
			require(['views/example/page'], function (ExamplePage) {
        var examplePage = Vm.create(appView, 'ExamplePage', ExamplePage);
        examplePage.render();
      });
		});
    
  };
  return {
    initialize: initialize
  };
});