Skip to content

Instantly share code, notes, and snippets.

@tommycutter
Created March 13, 2013 18:00
Show Gist options
  • Save tommycutter/5154572 to your computer and use it in GitHub Desktop.
Save tommycutter/5154572 to your computer and use it in GitHub Desktop.
Template for dynamic routes with PathJS
Path.map("#/activities(/:param1)(/:param2)").to(function(){
// View all activities
if(!this.params["param1"]) {
activitiesPage();
}
// Create a new activity
if(this.params["param1"] == 'create') {
activitiesCreatePage();
}
// View the activity
if($.isNumeric(this.params["param1"]) && !this.params["param2"]) {
activitiesDetailPage(this.params["param1"]);
}
// Edit the activity
if($.isNumeric(this.params["param1"]) && this.params["param2"] == 'edit') {
activitiesEditPage(this.params["param1"]);
}
// Delete the activity
if($.isNumeric(this.params["param1"]) && this.params["param2"] == 'delete') {
activitiesDeletePage(this.params["param1"]);
}
});
function activitiesPage() {
// activities landing page loaded
}
function activitiesDetailPage(id) {
// activities detail page loaded
}
function activitiesCreatePage() {
// create new activity page loaded
}
function activitiesEditPage(id) {
// edit activity page loaded
}
function activitiesDeletePage(id) {
// delete activity page loaded
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment