Load a tab only once

This commit is contained in:
Eelco Dolstra
2013-08-28 17:40:50 +02:00
parent 410060ec8a
commit 11acf0be28
+3 -1
View File
@@ -458,10 +458,12 @@ BLOCK makeLazyTab %]
</div>
<script>
$(function() {
var tabsLoaded = {};
$('.nav-tabs').bind('show', function(e) {
var pattern = /#.+/gi;
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) {
if (status == "error") {
$('#[% tabName %]').html("<div class='alert alert-error'>Error loading tab: " + xhr.status + " " + xhr.statusText + "</div>");