JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js"></script>
JavaScript
var MyRouter = Backbone.Router.extend({
routes: {
"": "home"
},
route: function(route, name, callback) {
return Backbone.Router.prototype.route.call(this, route, name, function() {
this.trigger.apply(this, ['beforeroute:' + name].concat(_.toArray(arguments)));
callback.apply(this, arguments);
});
},
home: function() {
alert("home!");
}
});
var router = new MyRouter()
router.on("beforeroute:home", function() {
alert("Home route is about to get hit ...");
});
Backbone.history.start();