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>
<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>");