using datatables with addtocalendar

using datatables with addtocalendar

crush123crush123 Posts: 417Questions: 126Answers: 18

I have a datatable containing event data populated via json/ajax
By default, the table shows only upcoming events, (ie those whose start date is >= today)
There is a form with a radio button which effectively removes the date filter and re-loads the ajax data to display all events.
So far so good.

I thought a great feature would be to add functionality to the table so that the user could add the event detail to GCal, iCal, outlook etc.

I sourced a (free) script from addtocalendar.com which works great on page load, but when I remove the filter and reload the ajax data, it no longer works.
There are no errors in my console, and would appreciate some help into how I can debug it.
Link to work in progress vanilla test page

http://test3.forthwebsolutions.com/vanilla_events.php

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,920Questions: 1Answers: 10,152 Site admin
    Answer ✓

    My guess is that AddToCalender is using static event listeners and is only searching for elements when it first runs. This is the same as the events FAQ.

    You'd need to read over the AddToCalender documentation (or code if there is none) to find out how to reinitialise it, or to have it use delegated event listeners.

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18

    Thanks Allan

    I remember you explaining delegated event listeners when i was having a similar issue with bootstrap tooltips on pagination.

    The AddToCalendar script wouldn;t play ball, but i found another one from https://www.addevent.com/ and this looks promising, when i add the script after the ajax reload

This discussion has been closed.