A
A
Alexander Timofeev2015-12-02 22:18:57
JavaScript
Alexander Timofeev, 2015-12-02 22:18:57

How can I make it so that when you follow a link, not only a new page opens, but also the necessary tab (bootstrap tabs) on it?

Made on bootstrap, install on modx

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
seriogja, 2015-12-11
@seriogja

Good day!
Everything seems to be in the documentation on the official website: getbootstrap.com/javascript/#tabs
You just have to write some additional code:

var url = document.location.toString();
if (url.match('#')) {
    $('.nav-tabs a[href=#'+url.split('#')[1]+']').tab('show') ;
} 

$('.nav-tabs a').on('shown.bs.tab', function (e) {
    window.location.hash = e.target.hash;
})

from here

S
Sergey Goryachev, 2015-12-02
@webirus

Is it me or do bootstrap tabs have anchors?
If so, then through link.ru/#anchor should work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question