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

Calendar not rendering until date changed or window resize

Open lyadeski opened this issue 10 years ago • 14 comments

Copied the sample directly from the http://angular-ui.github.io/ui-calendar/ page into my app. Only difference is my app uses UI-Router.

When page loads, no calendar is displayed, however the navigation buttons are such as the "today" button and the next and previous button. Click on any of the buttons OR resizing the window triggers the calendar to show. Can't figure out how to get the calendar to show on load w/ out doing the above.

lyadeski avatar Oct 27 '14 18:10 lyadeski

Anything in the console?

vubui avatar Oct 29 '14 15:10 vubui

Nope - no errors, everything appears fine. Works fine once i click one of the links. Can't get to show on load otherwise.

lyadeski avatar Oct 29 '14 15:10 lyadeski

I am also experiencing the same issue.

cjgreen avatar Nov 03 '14 05:11 cjgreen

same issue here, except a window resize does not cause the render to occur.

This only occurs for me when my data is still loading when the view is first digested. The modifications I make to the source array after all of my data loads do not seem to take effect immediately.

timcosta avatar Nov 12 '14 00:11 timcosta

Can someone create a plunker for this?

vubui avatar Nov 12 '14 16:11 vubui

Hi all, I had the same issue but i've fixed changing the last function of .directive('uiCalendar', ...) like this:

scope.$watch(getOptions, function(newO, oldO) {
            scope.destroy();
            $timeout(function(){scope.init()}); // Be sure to include $timeout
          });

I know that is not a perfect solution, but it works.. ^^ This is the Plunker

gise88 avatar Dec 01 '14 01:12 gise88

changing the function worked for me - can't see any major performance issues with it.

mortware avatar Feb 02 '15 10:02 mortware

+1 on this issue. fixed in https://github.com/angular-ui/ui-calendar/issues/174#issuecomment-65009816.

dougestey avatar Apr 07 '15 16:04 dougestey

Any other solution for this ??

ashiquemohammed avatar Aug 08 '15 12:08 ashiquemohammed

I have same issue. Tried #174, but it still not rendering after page reload.

aidarbuy avatar Feb 18 '16 12:02 aidarbuy

Fixed by adding to scope.init:

setTimeout(function () {
  calendar.fullCalendar('render');
});

aidarbuy avatar Feb 18 '16 13:02 aidarbuy

I have the same issue. I tried #174 comment and the suggestion above, but no fix yet.

fabrikate avatar May 05 '16 16:05 fabrikate

I've had to do what @aidarbuy did, but with a minimium of 100ms.

lnaia avatar May 14 '16 09:05 lnaia

In case anyone else is still facing this problem... here is the above suggestion for the current version of ui-calendar:

scope.$watch(getOptions, function(newValue, oldValue) {
          if(newValue !== oldValue) {
            scope.destroyCalendar();
            $timeout(function(){scope.initCalendar();}, 1000);
          } else if((newValue && angular.isUndefined(calendar))) {
            $timeout(function(){scope.initCalendar();}, 1000);
          }
        }); 

This is with a 1 second delay (1000ms). Unfortunately that's what I needed to get the events to render on load.

also make sure to add $timeout to the directive:

.directive('uiCalendar', ['uiCalendarConfig', '$timeout', function(uiCalendarConfig, $timeout)

ndevine avatar Aug 02 '18 20:08 ndevine