var AppRouter = Backbone.Router.extend({
routes: {
"": "defaultRoute",
"info": "info",
"message/:text" : "message",
"order/:item" : "order",
"order/:item/" : "order",
"order/:item/:count" : "order",
"*actions" : "pageNotFound"
},
defaultRoute: function () {
$('#main').html('
This is the default route
');
},
info: function () {
$('#main').html('This is the "Info" page
');
},
message: function (text) {
$('#main').html('The message you provided is: "' + text + '"
');
},
order: function (item,count) {
if (!count){count = 1};
$('#main').html('Order Details
Item: ' + item + '
Quantity: ' + count + '
');
},
pageNotFound: function () {
$('#main').html('Sorry, the page you requested was not found
');
}
});
var app = new AppRouter();
$(document).ready(function() {
Backbone.history.start();
});