Last active
August 27, 2018 15:35
-
-
Save andresgcarmona/028f0cdee54d1a997e9e9e3e8f53cd3e to your computer and use it in GitHub Desktop.
Backbone router.
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
class Router extends Backbone.Router { | |
contructor(options){ | |
} | |
get routes() { | |
return { | |
':section': 'showSection', | |
'*action': 'default', | |
}; | |
} | |
default() { | |
this.showSection('default'); | |
} | |
mostrarSeccion(section) { | |
var section = section || 'default'; | |
$('.section').addClass('hidden'); | |
$('.section#' + seccion).removeClass('hidden') | |
.find('form').removeClass('hidden'); | |
$('.tabs-container li a').removeClass('active'); | |
$('.tabs-container').find('li.' + section + ' a').addClass('active'); | |
} | |
}; | |
let router = new Router(); | |
// Initialize Backbone history. | |
if(!Backbone.History.started) { | |
Backbone.history.start({pushState: false}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment