-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Bootstrap/Tabs: remember active tabs #4890
Comments
Isn't it better to use cookie? If their are other anchors on page - not related to tabs - and user navigates them - |
Yes, we can use cookie for this - it is easy too. |
usually user storage in browser is used |
@Ragazzo, if you mean |
all modern browser supports it . Also i saw it already used in |
The key word is |
Can you show what browsers does not support it since it is |
I think you can implement the localStorage by default and if someone wants to be "bullet"browser"proof" you can make a comment about cookie storage |
http://caniuse.com/#feat=namevalue-storage |
Bootstrap 3.0 is only supported on browsers (and works) that support localstorage, you kinda in the wrong business if you are supporting old browsers (except for Opera Mini of couse :). |
So as we see here it is not a problem and we should use local storage |
As I said earlier: yes, it is not a big problem. We can use |
Workaround until this feature is added to Yii 2.1: <?php
$script = <<< JS
$(function() {
//save the latest tab (http://stackoverflow.com/a/18845441)
$('a[data-toggle="tab"]').on('click', function (e) {
localStorage.setItem('lastTab', $(e.target).attr('href'));
});
//go to the latest tab, if it exists:
var lastTab = localStorage.getItem('lastTab');
if (lastTab) {
$('a[href="'+lastTab+'"]').click();
}
});
JS;
$this->registerJs($script, yii\web\View::POS_END);
?> |
Issue moved to yiisoft/yii2-bootstrap#104 |
Just a feature request: config option to "remember" active tab in Tabs widget (to activate last opened tab after reloading the page).
It is not so hard to implement with application JS, but can be a feature of widget. We need to register just two event handlers:
location.hash
on tab click:We need this because of https://github.com/twbs/bootstrap/blob/master/js/tab.js#L126
2. On document ready activate the tab:
The text was updated successfully, but these errors were encountered: