ui-calendar icon indicating copy to clipboard operation
ui-calendar copied to clipboard

Event disappear after switching months

Open hzhou1-godaddy opened this issue 12 years ago • 44 comments

I was using this ui-calendar and found a issue that the event will disappear after switching to different months. The same issue happens on the demo here http://angular-ui.github.io/ui-calendar/

delete some existing event -> add new event -> move the event to a different date -> go to next month -> go back to the current month Then the new event will disappear. Note that the event is still on the list but just not on the calendar. I have tracked the behavior in the js console, and the source is still correct, but if I do $('#Calendar').fullCalendar( 'clientEvents' ); it does not show up that newly created event.

screen shot 2014-04-11 at 3 37 42 pm screen shot 2014-04-11 at 3 37 54 pm screen shot 2014-04-11 at 3 38 09 pm screen shot 2014-04-11 at 3 38 03 pm

hzhou1-godaddy avatar Apr 11 '14 22:04 hzhou1-godaddy

This is an issue with the fullcalendar library itself. It is a known issue that not event v2 of the calendar.js fixes.

joshkurz avatar Apr 13 '14 18:04 joshkurz

Is there a workaround for this issue? This would be a pretty serious issue for me since the calendar does not display correctly even the eventsource data is correct.

hzhou1-godaddy avatar Apr 14 '14 17:04 hzhou1-godaddy

I do not have a great solution for this atm. Honestly right now if this was plaguing my application I would have the renderEvent method in the calendar just do this

 eventsWatcher.onAdded = function(event) {
            scope.destroy();
            scope.init();
 };

as a simple workaround. This makes the calendar flash for a split second, but it's better than disappearing events.

joshkurz avatar Apr 27 '14 21:04 joshkurz

Hi joshkurz,

I followed your suggestion but it didn't work.

henyana avatar Apr 30 '14 08:04 henyana

henyana, for me it's working if I modify it as:

eventsWatcher.onAdded = function (event) {
            scope.calendar.fullCalendar('renderEvent', event);
            scope.destroy();
            getOptions(); //Probl. you need to take the options again.
            scope.init();
        };

Anyway, it provokes the refresh of the calendar, so if the user has move to another screen, it will return to the first one. Is the same if you click 'Hungarian' button in the demo.

When the eventsWatcher.onAdded() calls renderEvent(), the 'stick' property is always undefined.

From fullCalendar documentation:

Normally, the event will disappear once the calendar refetches its event sources (example: when prev/next is clicked). However, specifying stick as true will cause the event to be permanently fixed to the calendar.

So, Why (before deleting) the events are 'sticky' if the property is undefined? And, if the problem comes from fullCalendar library, do you know if is any issue/bug open in its project?

M0nter0 avatar Jun 05 '14 09:06 M0nter0

I do not think there is an official issue. On Jun 5, 2014 5:52 AM, "vanHuntsman" [email protected] wrote:

henyana, for me it's working if I modify it as:

eventsWatcher.onAdded = function (event) { scope.calendar.fullCalendar('renderEvent', event); scope.destroy(); getOptions(); //Probl. you need to take the options again. scope.init(); };

Anyway, it provokes the refresh of the calendar, so if the user has move to another screen, it will return to the first one. Is the same if you click 'Hungarian' button in the demo.

When the eventsWatcher.onAdded() calls renderEvent(), the 'stick' property is always undefined.

From fullCalendar documentation:

Normally, the event will disappear once the calendar refetches its event sources (example: when prev/next is clicked). However, specifying stick as true will cause the event to be permanently fixed to the calendar.

So, Why (before deleting) the events are 'sticky' if the property is undefined? And, if the problem comes from fullCalendar library, do you know if is any issue/bug open in its project?

— Reply to this email directly or view it on GitHub https://github.com/angular-ui/ui-calendar/issues/99#issuecomment-45200846 .

joshkurz avatar Jun 05 '14 09:06 joshkurz

Hi joshkurz, I've try to reproduce this behavior directly in fullCalendar to open an official issue. I've create a JSFiddle you can see here: http://jsfiddle.net/vanHuntsman/KzADf/1/ If we add events with 'stick' property as undefined, as documentation says, those events disappear when the calendar refetches.

Why do you think is an issue with the fullcalendar library itself? Should not the eventsWatcher.onAdded() set the stick property to true? What I don't really get is why when eventsWatcher.onAdded() calls renderEvent with 'stick' undefined the events are 'sticky' (what is the opposite the doc says).

In fact, if instead of adding the event to the array that is being watched by the eventsWatcher I call

$('#myCalendar').fullCalendar('renderEvent', myEvent, true);

Then it works good.

M0nter0 avatar Jun 05 '14 13:06 M0nter0

I did add stick === true to the calendar before, but I ran into another issue. see https://github.com/angular-ui/ui-calendar/issues/85

On Thu, Jun 5, 2014 at 9:23 AM, vanHuntsman [email protected] wrote:

Hi joshkurz, I've try to reproduce this behavior directly in fullCalendar to open an official issue. I've create a JSFiddle you can see here: http://jsfiddle.net/vanHuntsman/KzADf/1/ If we add events with 'stick' property as undefined, as documentation says, those events disappear when the calendar refetches.

Why do you think is an issue with the fullcalendar library itself? Should not the eventsWatcher.onAdded() set the stick property to true? What I don't really get is why when eventsWatcher.onAdded() calls renderEvent with 'stick' undefined the events are 'sticky' (what is the opposite the doc says).

In fact, if instead of adding the event to the array that is being watched by the eventsWatcher I call

$('#myCalendar').fullCalendar('renderEvent', myEvent, true);

Then it works good.

— Reply to this email directly or view it on GitHub https://github.com/angular-ui/ui-calendar/issues/99#issuecomment-45218053 .

Josh Kurz www.joshkurz.net

joshkurz avatar Jun 05 '14 14:06 joshkurz

I want to make clear though that I am not ruling uiCalendar out of the equation still though. Just have not found the perfect solution yet.

On Thu, Jun 5, 2014 at 10:11 AM, Josh Kurz [email protected] wrote:

I did add stick === true to the calendar before, but I ran into another issue. see https://github.com/angular-ui/ui-calendar/issues/85

On Thu, Jun 5, 2014 at 9:23 AM, vanHuntsman [email protected] wrote:

Hi joshkurz, I've try to reproduce this behavior directly in fullCalendar to open an official issue. I've create a JSFiddle you can see here: http://jsfiddle.net/vanHuntsman/KzADf/1/ If we add events with 'stick' property as undefined, as documentation says, those events disappear when the calendar refetches.

Why do you think is an issue with the fullcalendar library itself? Should not the eventsWatcher.onAdded() set the stick property to true? What I don't really get is why when eventsWatcher.onAdded() calls renderEvent with 'stick' undefined the events are 'sticky' (what is the opposite the doc says).

In fact, if instead of adding the event to the array that is being watched by the eventsWatcher I call

$('#myCalendar').fullCalendar('renderEvent', myEvent, true);

Then it works good.

— Reply to this email directly or view it on GitHub https://github.com/angular-ui/ui-calendar/issues/99#issuecomment-45218053 .

Josh Kurz www.joshkurz.net

Josh Kurz www.joshkurz.net

joshkurz avatar Jun 05 '14 14:06 joshkurz

Thanks for the links @joshkurz I´ve try as well adding always stick = true, but then begins to be very unstable. It seems that doubles events when the date is not in the current view. The event appear in its source, but as well in stickySource.events.

function renderEvent(event, stick) {
        normalizeEvent(event);
        if (!event.source) {
            if (stick) {
                stickySource.events.push(event); // First addition
                event.source = stickySource;
            }
            cache.push(event); // Second addition
        }
        reportEvents(cache);
    }

Although adding and removing events directly calling .fullCalendar('renderEvent'...) is working ok for me, I'm really interested in making it run with the power of angular watchs provide by uiCalendar. If I could help anyway, let me know. I've try to isolate the problem just using fullCalendar to report a bug without results. Anyway, I'm using fullCalendar v1.6.4 and Ui.Calendar v0.8.0, and the efforts should continue to integrate uiCalendar in fullCalendar2.

M0nter0 avatar Jun 05 '14 15:06 M0nter0

Yes, what we need to do is prove where the bug lives, by creating a failing test. fullcalendar.js has incorporated a sweet of many tests, which will be easy to add too. If we can show a test with these results using just fullcalendar, then we will know for sure where the real issue is.

I have checked the $scope's events array to see if items are being duplicated or removed, but it is not the case. I figured that if the model is correct and the view is wrong, the only reasonable explanation is what is creating the view. The directive is only detecting what fullcalendar method to call, so its really just the glue between the $scope.events and how the fullcaelndar is rendering the view based on the events data model.

On Thu, Jun 5, 2014 at 11:27 AM, vanHuntsman [email protected] wrote:

Thanks for the links @joshkurz https://github.com/joshkurz I´ve try as well adding always stick = true, but then begins to be very unstable. It seems that doubles events when the date is not in the current view. The event appear in its source, but as well in stickySource.events.

function renderEvent(event, stick) { normalizeEvent(event); if (!event.source) { if (stick) { stickySource.events.push(event); // First addition event.source = stickySource; } cache.push(event); // Second addition } reportEvents(cache); }

Although adding and removing events directly calling .fullCalendar('renderEvent'...) is working ok for me, I'm really interested in making it run with the power of angular watchs provide by uiCalendar. If I could help anyway, let me know. I've try to isolate the problem just using fullCalendar to report a bug without results. Anyway, I'm using fullCalendar v1.6.4 and Ui.Calendar v0.8.0, and the efforts should continue to integrate uiCalendar in fullCalendar2.

— Reply to this email directly or view it on GitHub https://github.com/angular-ui/ui-calendar/issues/99#issuecomment-45233921 .

Josh Kurz www.joshkurz.net

joshkurz avatar Jun 05 '14 15:06 joshkurz

Any updates on this? Seems like a pretty major problem.

dannydinges avatar Jul 25 '14 03:07 dannydinges

I created pull request #140, this is the fix I am currently using

ctesene avatar Aug 08 '14 17:08 ctesene

I'm not sure if thats related, but I just fixed a similar issue. When i modified a date than switched the calendar view (day/week/next month), the event would desapear. When i checked the object before and after, i noticed that the date object type changed from FCMoment to Moment. To fix the issue, I simply had to convert the Moment to a FCMoment using $.fullCalendar.moment(date, format). (My guess is that the same thing happens when you give it a String or a Date)

Unitiser avatar Sep 27 '14 18:09 Unitiser

just go to your calendar.js and change onAdded eventsWatcher.onAdded = function(event) { scope.calendar.fullCalendar('renderEvent', event,true); }; Work's for me :+1:

linkolen avatar Oct 12 '14 08:10 linkolen

@Unitiser , @linkolen , in which version are those suggestions based? @linkolen, your suggestion on Ui.Calendar v0.8.0 provokes the duplication of the slots when the date of add is not in the current window view.

M0nter0 avatar Oct 13 '14 08:10 M0nter0

@vanHuntsman the last one i used this link https://github.com/angular-ui/ui-calendar/blob/master/src/calendar.js#L251

i also used this tutorial http://www.oodlestechnologies.com/blogs/Fullcalendar-Walk-through-with-AngularJS

linkolen avatar Oct 13 '14 09:10 linkolen

@linkolen thanks. Your solution, worked for me. By passing the third argument as true, to fullCalendar, the events are now sticking.

desertzebra avatar Nov 06 '14 14:11 desertzebra

@desertzebra you are welcome.

linkolen avatar Nov 09 '14 15:11 linkolen

Awesome guys. @linkolen thanks and also @m0nter0 for adding the reference. Maybe we need a pr for this.

alexanderchan avatar Dec 08 '14 16:12 alexanderchan