forked from lix-project/hydra
Fix lazy tab loading
This commit is contained in:
parent
9602499c1c
commit
24c757845d
|
@ -459,21 +459,7 @@ BLOCK makeLazyTab %]
|
||||||
<center><img src="/static/images/ajax-loader.gif" alt="Loading..." /></center>
|
<center><img src="/static/images/ajax-loader.gif" alt="Loading..." /></center>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() { makeLazyTab("[% tabName %]", "[% uri %]"); });
|
||||||
var tabsLoaded = {};
|
|
||||||
$('.nav-tabs').bind('show', function(e) {
|
|
||||||
var pattern = /#.+/gi;
|
|
||||||
var id = e.target.toString().match(pattern)[0];
|
|
||||||
if (id == "#[% tabName %]" && !tabsLoaded[id]) {
|
|
||||||
tabsLoaded[id] = 1;
|
|
||||||
$('#[% tabName %]').load("[% uri %]", function(response, status, xhr) {
|
|
||||||
if (status == "error") {
|
|
||||||
$('#[% tabName %]').html("<div class='alert alert-error'>Error loading tab: " + xhr.status + " " + xhr.statusText + "</div>");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
[% END;
|
[% END;
|
||||||
|
|
||||||
|
|
|
@ -71,3 +71,20 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var tabsLoaded = {};
|
||||||
|
|
||||||
|
var makeLazyTab = function(tabName, uri) {
|
||||||
|
$('.nav-tabs').bind('show', function(e) {
|
||||||
|
var pattern = /#.+/gi;
|
||||||
|
var id = e.target.toString().match(pattern)[0];
|
||||||
|
if (id == '#' + tabName && !tabsLoaded[id]) {
|
||||||
|
tabsLoaded[id] = 1;
|
||||||
|
$('#' + tabName).load(uri, function(response, status, xhr) {
|
||||||
|
if (status == "error") {
|
||||||
|
$('#' + tabName).html("<div class='alert alert-error'>Error loading tab: " + xhr.status + " " + xhr.statusText + "</div>");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue