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

Bootstrap/Tabs: remember active tabs #104

Open
yii-bot opened this issue Jan 24, 2016 · 3 comments
Open

Bootstrap/Tabs: remember active tabs #104

yii-bot opened this issue Jan 24, 2016 · 3 comments
Labels
status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement

Comments

@yii-bot
Copy link

yii-bot commented Jan 24, 2016

This issue has originally been reported by @RomeroMsk at yiisoft/yii2#4890.
Moved here by @cebe.


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:

  1. Set location.hash on tab click:
$(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
    location.hash = e.target.hash;
});

We need this because of https://github.com/twbs/bootstrap/blob/master/js/tab.js#L126
2. On document ready activate the tab:

$(document).ready(function() {
    if (location.hash.length) {
        $('[data-toggle="tab"], [data-toggle="pill"]').filter('[href="' + location.hash + '"]').tab('show');
    }
}
@melledijkstra
Copy link

melledijkstra commented Dec 2, 2017

@cebe Is this already implemented? Or is this still in development?

@schmunk42
Copy link
Contributor

We implemented this with local storage a while ago. https://github.com/dmstr/yii2-bootstrap But the code should be cleaned.

@melledijkstra
Copy link

@schmunk42 Thanks! Would be nice if they implement it into yii2

@machour machour added type:enhancement Enhancement status:ready for adoption Feel free to implement this issue. labels Jan 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement
Projects
None yet
Development

No branches or pull requests

4 participants