I am using visjs timeline to make a timeline and I have a button that redraws that timeline on click event. The redrawing is done by getting data from timeline.php using AJAX but the data received doesn't work in DataSet!
Here is what I've got so far:
The function that is triggered when I click on button:
function redrawTL(){
$.ajax({
type: "POST", url: "ajax/timeline.php", data: {},
success: function(data){
redraw(data);
}
});
}
The function that should redraw the timeline assuming I already have set the variables items and tl
function redraw(data){
console.log(data);
items = new vis.DataSet([ data ]); // This doesn't!!
tl.destroy();
tl = new vis.Timeline(container, items, options);
}
So my question is why it doesn't work?! Knowing that the data is shown in console.
Data is supposed to be filled with the following data:
{id: 0, content: '07:10:12', start: today.clone().add(25606, 'seconds'), 'className': 'tmstyle'},
{id: 1, content: '00:40:06', start: today.clone().add(56563, 'seconds'), 'className': 'arretNU'},
{id: 2, content: '00:01:07', start: today.clone().add(63312, 'seconds'), 'className': 'arretNU'},
{id: 3, content: '00:00:16', start: today.clone().add(63389, 'seconds'), 'className': 'arretNU'}
And if I make the redraw function static it works fine.