brospars / simple-calendar

Simple calendar jquery plugin
https://brospars.github.io/simple-calendar
MIT License
49 stars 38 forks source link

Question: Ability to add Events? #17

Closed valerio-bozzolan closed 3 years ago

valerio-bozzolan commented 4 years ago

Hello!

Just a question. Is it possible to update Events after initialization?

I tried calling again $calendar.simpleCalendar( { events: myEvents } ) but without much success, but maybe I'm doing something wrong.

Thank you :)

valerio-bozzolan commented 4 years ago

P.S.

Inspecting the source code I've found this undocumented way that seems to work:

$calendar.data('plugin_simpleCalendar').settings.events = myEvents;

A very ugly workaround I think.

brospars commented 4 years ago

Yes I wanted to implements methods to add or access events. PR welcome !

edcaron commented 4 years ago

Ugly workaround

$("#calendar").simpleCalendar().data('plugin_simpleCalendar').settings.events =  [ ];

var currentDate = $("#calendar").simpleCalendar().data('plugin_simpleCalendar').currentDate;
var calendar    = $("#calendar").find('.calendar');

$("#calendar").simpleCalendar().data('plugin_simpleCalendar').buildCalendar(currentDate, calendar);
AidosMarcos commented 4 years ago

Any news about this development? The workaround talked here does not work, data('plugin_simpleCalendar') gives me undefined.

I need to update displayed event depending of a user choice.

Any way to update calendar, or destroy instance and initiate again?

monsterbrain commented 4 years ago

I've added a new PR with the above mentioned adding event functionality. @AidosMarcos @brospars

brospars commented 3 years ago

Close by #32