Stay on the same tab
This commit is contained in:
		
							parent
							
								
									fa85920043
								
							
						
					
					
						commit
						8e6cf99b08
					
				| 
						 | 
					@ -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>
 | 
				
			||||||
		Loading…
	
		Reference in New Issue