This document discusses using the JavaScript framework Backbone.js in Drupal. It begins by explaining why JavaScript matters for modern web development. It then introduces Backbone and its key concepts like the model-view-controller (MVC) pattern. Specific Backbone components are demonstrated, like models, templates, collections, views, routing, and using the Underscore.js library. Ways to incorporate Backbone in a Drupal module are presented. The document concludes by mentioning additional Backbone resources and posing questions.
20. Routing
var AppRouter = Backbone.Router.extend({
routes: { "posts/:id": "getPost"}});
var app_router = new AppRouter;
app_router.on('route:getPost', function (id)
{
alert( "Get post number " + id );
});
Backbone.history.start();