Last active
August 29, 2015 14:04
-
-
Save bahelms/b631f423c4090c87042e to your computer and use it in GitHub Desktop.
Default to previous active tab after page reload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery -> | |
checkLocalStorage = -> | |
lastTab = localStorage.getItem("name_of_saved_item") | |
if lastTab | |
# Set active tab to previous tab from before page reload | |
$("a[href='#{lastTab}']").tab("show") | |
localStorage.removeItem("name_of_saved_item") | |
# Execute every time page is loaded | |
checkLocalStorage() | |
# At some point before the page is reloaded, set the item to remember (ie, href of active tab): | |
localStorage.setItem("name_of_saved_item", "value_of_saved_item") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment