Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

easily add an event (via renderEvent) to a specific event source #2537

Closed
arshaw opened this issue Aug 19, 2015 · 5 comments
Closed

easily add an event (via renderEvent) to a specific event source #2537

arshaw opened this issue Aug 19, 2015 · 5 comments
Assignees

Comments

@arshaw
Copy link
Member

arshaw commented Aug 19, 2015

Originally reported on Google Code with ID 2272

Hi everyone !
First I would like to thank all of you for this amazing plugin !
I am facing the following issue :
I would like to dynamically add an event to a source, and I am wondering if it is even
possible.

Let us take the following example :
http://jsfiddle.net/88562sxa/
I have a source : v with one event inside.
I also have an event ev. Its source references v.
When I add the event source to the calendar, everything is fine.
However, when I want to render the ev event, it does not appear on the calendar. The
source v -even when referenced in source attribute of ev- does not change at all.
Is it normal ?
Is there an other way to dynamically add an event to a source ?

Thanks in advance !
Regards,
Julien Orain





Reported by julien.orain on 2014-09-01 22:32:47

Imported with 1 stars.

@arshaw
Copy link
Member Author

arshaw commented Aug 19, 2015

this functionality is better achieved with an event source *as a function* or *as a
JSON feed*
http://arshaw.com/fullcalendar/docs/event_data/events_function/
http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/

but if you need to keep it in an array, you can use update your array, and use removeEventSource
followed be re-adding it via addEventSource
http://arshaw.com/fullcalendar/docs/event_data/removeEventSource/
http://arshaw.com/fullcalendar/docs/event_data/addEventSource/

But there maybe should be a more convenient way. Especially if you want to dynamically
add an event (via the renderEvent method) and want it to be associated with a specific
Event Source Object because you want to leverage some of the Event Source Object Properties,
like colors and such.

Reported by adamrshaw on 2014-09-02 07:18:27

  • Status changed: Accepted
  • Labels added: Type-Feature

@arshaw
Copy link
Member Author

arshaw commented Aug 19, 2015

Hi Adam !
So I used add/remove source to re add sources and everything is fine now ! Yeah, maybe
a more convenient way could be found.
Thanks for the tip ;-)
Julien

Reported by julien.orain on 2014-09-03 23:09:06

@JobaDiniz
Copy link

It would be really nice to accept not only an event object, but any obj and then use the eventDataTransform function.

var source = {
                id: agenda.id,
                events: function (start, end, timezone, callback) {
                    Appointment.all(agenda.id, start, end)
                        .then(function (appointments) {
                            callback(appointments);
                        })
                        .catch(function (error) {
                            callback([]);
                        });
                },
                eventDataTransform: eventDataTransform,
                backgroundColor: agenda.backgroundColor,
                textColor: agenda.textColor,
                borderColor: agenda.borderColor
            };

Now, I want to add an appointment. It would call eventDataTransform and everything would work.

@arshaw
Copy link
Member Author

arshaw commented Jun 12, 2016

@JobaDiniz if you already have a handle to your eventDataTransform function, why not run your raw event data through it before passing it to renderEvents? Would achieve the same thing but without having to run it through FullCalendar's API.

@arshaw arshaw closed this as completed Jun 12, 2016
@arshaw arshaw removed the Accepted label Jun 12, 2016
@raghav-axero
Copy link

raghav-axero commented Sep 18, 2016

Hi Arshaw,

Any estimated date when this feature will be implemented in core?

I want to add events to eventsource dynamically i.e after the calendar is rendered and event sources are already set.

Removing event source and re-adding it just to add one new event to event source doesn't look good and practical.

Posted a similar question here http://stackoverflow.com/questions/39559106/list-of-events-under-a-particular-event-source-in-full-calendar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants