Stay on the same tab
This commit is contained in:
		
							parent
							
								
									fa85920043
								
							
						
					
					
						commit
						8e6cf99b08
					
				| 
						 | 
				
			
			@ -275,20 +275,17 @@ delete locales;
 | 
			
		|||
    }); 
 | 
			
		||||
  </script>
 | 
			
		||||
<% end %>
 | 
			
		||||
<script>
 | 
			
		||||
  $(document).ready(function () {
 | 
			
		||||
 
 | 
			
		||||
    if (location.hash.substr(0,2) == "#") {
 | 
			
		||||
      $("a[href='#" + location.hash.substr(2) + "']").tab("show");
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
    $("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);
 | 
			
		||||
        }
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
$(function() { 
 | 
			
		||||
  $('a[data-toggle="tab"]').on('click', function (e) {
 | 
			
		||||
    var tab = $(this).attr('href');
 | 
			
		||||
    localStorage.setItem('lastTab', tab);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  //go to the latest tab, if it exists:
 | 
			
		||||
  var lastTab = localStorage.getItem('lastTab');
 | 
			
		||||
  if (lastTab) {
 | 
			
		||||
    $('a[href='+lastTab+']').click();
 | 
			
		||||
  }
 | 
			
		||||
});
 | 
			
		||||
</script>
 | 
			
		||||
		Loading…
	
		Reference in New Issue