Generalize lazy tabs

This commit is contained in:
Eelco Dolstra
2013-02-22 13:36:15 +01:00
parent e2e973578f
commit 47d2ee0dab
2 changed files with 24 additions and 21 deletions

View File

@ -448,4 +448,25 @@ BLOCK renderEvals %]
BLOCK renderLogLinks %]
(<a href="[% url %]">log</a>, <a href="[% "$url/raw" %]">raw</a>, <a href="[% "$url/tail-reload" %]">tail</a>)
[% END %]
[% END;
BLOCK makeLazyTab %]
<div id="[% tabName %]" class="tab-pane">
<center><img src="/static/images/ajax-loader.gif" alt="Loading..." /></center>
</div>
<script>
$(function() {
$('.nav-tabs').bind('show', function(e) {
var pattern = /#.+/gi;
var id = e.target.toString().match(pattern)[0];
if (id == "#[% tabName %]") {
$('#[% tabName %]').load("[% uri %]");
}
});
});
</script>
[% END;
%]