Skip to content

Instantly share code, notes, and snippets.

@andresgcarmona
Last active August 27, 2018 15:35
Show Gist options
  • Save andresgcarmona/028f0cdee54d1a997e9e9e3e8f53cd3e to your computer and use it in GitHub Desktop.
Save andresgcarmona/028f0cdee54d1a997e9e9e3e8f53cd3e to your computer and use it in GitHub Desktop.
Backbone router.
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