diff --git a/src/root/common.tt b/src/root/common.tt index 79ca3bd5..42bf4224 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -459,21 +459,7 @@ BLOCK makeLazyTab %]
Loading...
[% END; diff --git a/src/root/static/js/common.js b/src/root/static/js/common.js index 7477455b..bbddd470 100644 --- a/src/root/static/js/common.js +++ b/src/root/static/js/common.js @@ -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("
Error loading tab: " + xhr.status + " " + xhr.statusText + "
"); + } + }); + } + }); +}