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,4 +1,6 @@
BR.TrackMessages = L.Class.extend({
// true when tab is shown, false when hidden
active: false,
columnOptions: {
'Longitude': { visible: false },
@ -10,7 +12,9 @@ BR.TrackMessages = L.Class.extend({
'TurnCost': { title: 'turncost', className: 'dt-body-right' }
},
initialize: function () {
initialize: function (options) {
L.setOptions(this, options);
var table = document.getElementById('datatable');
this.tableClassName = table.className;
this.tableParent = table.parentElement;
@ -24,6 +28,9 @@ BR.TrackMessages = L.Class.extend({
headings,
table;
if (!this.active)
return;
for (i = 0; segments && i < segments.length; i++) {
messages = segments[i].feature.properties.messages;
data = data.concat(messages.slice(1));
@ -54,6 +61,15 @@ BR.TrackMessages = L.Class.extend({
console.timeEnd('datatable');
},
show: function() {
this.active = true;
this.options.requestUpdate(this);
},
hide: function() {
this.active = false;
},
_destroyTable: function() {
var ele;