don't update table when data tab hidden, update when shown

This commit is contained in:
Norbert Renner 2014-09-05 19:19:14 +02:00
parent 2ab15561a8
commit 44900f9bd5
3 changed files with 56 additions and 6 deletions

View file

@ -1,14 +1,34 @@
BR.Tabs = BR.Control.extend({
options: {
divId: 'tabs_div'
divId: 'tabs_div',
// tab a.hash > instance
tabs: {}
},
initialize: function (options) {
L.setOptions(this, options);
},
onAdd: function (map) {
$('#tab a').click(function (e) {
e.preventDefault();
$(this).tab('show');
e.preventDefault();
$(this).tab('show');
});
// e.target = activated tab
// e.relatedTarget = previous tab
$('#tab a').on('shown.bs.tab', L.bind(function (e) {
var tab = this.options.tabs[e.target.hash],
prevTab = this.options.tabs[e.relatedTarget.hash];
if (tab && tab.show) {
tab.show();
}
if (prevTab && prevTab.hide) {
prevTab.hide();
}
}, this));
return BR.Control.prototype.onAdd.call(this, map);
}
});