1
0
Fork 0
mirror of https://github.com/NixOS/hydra.git synced 2024-10-18 17:02:28 -04:00

Load a tab only once

This commit is contained in:
Eelco Dolstra 2013-08-28 10:05:01 +00:00
parent 410060ec8a
commit 11acf0be28

View file

@ -458,10 +458,12 @@ BLOCK makeLazyTab %]
</div> </div>
<script> <script>
$(function() { $(function() {
var tabsLoaded = {};
$('.nav-tabs').bind('show', function(e) { $('.nav-tabs').bind('show', function(e) {
var pattern = /#.+/gi; var pattern = /#.+/gi;
var id = e.target.toString().match(pattern)[0]; var id = e.target.toString().match(pattern)[0];
if (id == "#[% tabName %]") { if (id == "#[% tabName %]" && !tabsLoaded[id]) {
tabsLoaded[id] = 1;
$('#[% tabName %]').load("[% uri %]", function(response, status, xhr) { $('#[% tabName %]').load("[% uri %]", function(response, status, xhr) {
if (status == "error") { if (status == "error") {
$('#[% tabName %]').html("<div class='alert alert-error'>Error loading tab: " + xhr.status + " " + xhr.statusText + "</div>"); $('#[% tabName %]').html("<div class='alert alert-error'>Error loading tab: " + xhr.status + " " + xhr.statusText + "</div>");