ka215 / jquery.timeline

You can easily create the horizontal timeline with two types by using this jQuery plugin.
MIT License
240 stars 43 forks source link

Remote events data #95

Open DeltaServiceSoftware opened 10 months ago

DeltaServiceSoftware commented 10 months ago

Hi, Is it possible to receive event data, in json format, from a remote resource? Thanks for help.

ka215 commented 10 months ago

Yes, you can do this by generating or updating the timeline after fetching the remote JSON data. Example of generating a timeline after fetching JSON data:

fetch("/path/to/getJsonEvents").then(response => {
  if (response.ok) {
    const events = response.json();
    $('#my-timeline').Timeline({ eventData: events });
  }
});

Or, example of obtaining and adding JSON data for an event to an already generated timeline:

$('#my-timeline').Timeline();

fetch("/path/to/getJsonEvents").then(response => {
  if (response.ok) {
    const events = response.json();
    $('#my-timeline').Timeline('addEvent', events);
  }
});

Best to try.

DeltaServiceSoftware commented 10 months ago
Timeline

It works! Thanks so much