Stay on the same tab

This commit is contained in:
saurabhbhatia 2013-11-28 11:01:21 +08:00
parent fa85920043
commit 8e6cf99b08
1 changed files with 12 additions and 15 deletions

View File

@ -275,20 +275,17 @@ delete locales;
}); });
</script> </script>
<% end %> <% end %>
<script> <script type="text/javascript">
$(document).ready(function () { $(function() {
$('a[data-toggle="tab"]').on('click', function (e) {
if (location.hash.substr(0,2) == "#") { var tab = $(this).attr('href');
$("a[href='#" + location.hash.substr(2) + "']").tab("show"); localStorage.setItem('lastTab', tab);
}
$("a[data-toggle='tab']").on("shown", function (e) {
var hash = $(e.target).attr("href");
if (hash.substr(0,1) == "#") {
location.replace("#" + hash.substr(1));
console.log(location.hash);
}
});
}); });
//go to the latest tab, if it exists:
var lastTab = localStorage.getItem('lastTab');
if (lastTab) {
$('a[href='+lastTab+']').click();
}
});
</script> </script>