Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using crossroads routes with bootstrap tabs #137

Open
liammcsheffrey opened this issue Aug 13, 2015 · 1 comment
Open

using crossroads routes with bootstrap tabs #137

liammcsheffrey opened this issue Aug 13, 2015 · 1 comment

Comments

@liammcsheffrey
Copy link

Hi,
I'm trying to set up crossroads.js to work with bootstrap tabs, so a URL may be /mainpage#latestnews

Looking at hasher and history.js, is there an example as to how this can work and how hash tab routes can be created?

Thanks

@rain-sk
Copy link

rain-sk commented Dec 10, 2016

(with jQuery) I use

$(window).on('hashchange', function(e){ // code to switch bootstrap tabs });

Based on the answer from the following SO question...

https://stackoverflow.com/questions/17830590/bootstrap-tab-activation-with-jquery

your implementation could look something like:


// detect hashchange
$(window).on('hashchange', function(e){

  // clean #hash
  var hash = window.location.hash.substr(1);

  // "show" the tab with #{hash} url
  $('.nav-tabs a[href="#' + hash + '"]').tab('show');

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants