Created
March 20, 2012 20:00
-
-
Save OndeVai/2140686 to your computer and use it in GitHub Desktop.
Sammy Routing Skeleton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//all should be wrapped in jquery func | |
var my = my || {}; | |
//routes setup | |
my.routes = (function () { | |
var hashBang = '#!/', //here could check if browser supports pushstate and avoid the hashbang | |
createRoute = function (route) { | |
return hashBang + route; | |
}; | |
return { | |
createRoute: createRoute | |
}; | |
})(); | |
//sammy setup | |
my.sammyRouter = $.sammy('[jquery selector]', function () { | |
var saveContext = null; | |
this.get(my.routes.createStepRoute('route with params'), function (context) { | |
saveContext = context; | |
//can perform model updates & validation (KO) | |
//could redirect based on validation | |
}); | |
this.after(function () { | |
//saveContext | |
//can perform after all routes exec | |
}); | |
}); | |
//start sammy | |
my.sammyRouter.run('initial route'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment