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

Calendar not showing first time angular 1.3

Open santimacia opened this issue 10 years ago • 20 comments

I made a plunker with the code from the demo, with angular 1.2 is working but with 1.3 the first time is not showing. This issue only happens when are inside a ui-bootstrap tabs.

http://plnkr.co/edit/atmJIY?p=preview

santimacia avatar Apr 09 '15 13:04 santimacia

Is there any known work around for this? Trying to avoid migrating back to 1.2.x just for this issue.

randalCare avatar Apr 16 '15 00:04 randalCare

+1

comapedrosa avatar Apr 27 '15 07:04 comapedrosa

+1

kszela24 avatar May 06 '15 07:05 kszela24

Same issue here. On first render, its not there. This only happens with Angular 1.3.

311chaos avatar May 06 '15 16:05 311chaos

+1

diosney avatar May 08 '15 18:05 diosney

This is related to Angular 1.3/bootstrap/ and the calendar. Not 100% what it is. The calendar renders fine without being set in tabs. It also renders fine if inside a set timeout. So I think it has to be some type of async DOM issue related to how directives are compiled in 1.3.x, but not sure.

joshkurz avatar May 09 '15 04:05 joshkurz

@joshkurz - Good to hear about the set timeout, I was thinking about trying something like that. In my scenario changing the date will trigger the cal to show.

311chaos avatar May 09 '15 06:05 311chaos

yeah I think if we do something like this it might actually work without us doing anything. https://github.com/angular-ui/ui-calendar/pull/104

joshkurz avatar May 09 '15 06:05 joshkurz

Any updates on this issue?

comapedrosa avatar Jun 02 '15 17:06 comapedrosa

for now, i just use ,

    /* Change View */
    $scope.renderCalender = function (calendar) {
        if (uiCalendarConfig.calendars[calendar]) {
            console.log('.', uiCalendarConfig.calendars[calendar]);
            uiCalendarConfig.calendars[calendar].fullCalendar('render');
        }
    };

    $timeout(function () {
        $scope.renderCalender('calendar');
    }, 1000);

devmark avatar Jun 30 '15 08:06 devmark

+1 I have this issue on angular 1.4.1 as well

dohomi avatar Jun 30 '15 10:06 dohomi

+1 I'm using angular 1.4.3

I tried the v2 branch and this renders, but it doesn't seem to be updating the events when I change them. I'll see if I can look into it.

internetErik avatar Jul 21 '15 17:07 internetErik

+1 I'm facing the exact same issue using angular 1.3 Any updates on this?

@devmark Thanks for your solution. I tried but it did not work for me.

limjunyangleon avatar Jul 24 '15 19:07 limjunyangleon

you can read example. also u need to inject uiCalendarConfig

devmark avatar Jul 25 '15 01:07 devmark

Thanks for your reply devmark.

I'm currently using this method to get my calendar to render the first time. Thought it might come in handy to anyone who is also facing this problem.

$scope.renderCalendar = function (calendarId) {
    $timeout(function () {
        calendarTag = $('#' + calendarId);
        calendarTag.fullCalendar('render');
    }, 0);
};

On tab select, the renderCalendar method is invoked. This method takes in a calendar ID which I set for my calendar, in this case, "someCalendarId", and I am forcing it to render the calendar based on the calendar id I passed in.

<div class="calendar" ng-model="eventsModel" calendar="myCalendar"
                             ui-calendar="uiConfig.calendar" id="someCalendarId"></div>

<tab select="renderCalendar('someCalendarId');">

limjunyangleon avatar Aug 04 '15 19:08 limjunyangleon

@limjunyangleon your snippet it's a good way to solve this issue. :+1:

comapedrosa avatar Aug 05 '15 09:08 comapedrosa

+1 @devmark your method worked for me

fabianTMC avatar Aug 15 '15 08:08 fabianTMC

Couple things

I don't believe its necessary to do full render, 'rerenderEvents' works fine. From the console I did following:

$('div[ui-calendar]').fullCalendar('rerenderEvents');

Although @limjunyangleon your fix works, the angular purists will say do not do DOM manipulation in the controller. Of course when stuck in the mud, sometimes you don't have a choice.

For me, I was just using ng-show/hide to toggle between a list view of events and fullcalendar. Changing the ng-show to be ng-if was a much simpler means to my end.

dandoyon avatar Jun 25 '16 16:06 dandoyon

None of the proposed solutions worked for me, but what DID work was to simply hide and then show the calendar div again after my events were loaded. Didn't even need to use a $timeout.

ie in the view:

<div ng-if="vm.showCal" class="calendar" ng-model="eventsModel" calendar="myCalendar" ui-calendar="uiConfig.calendar" id="someCalendarId"></div>

and in the controller:

vm.showCal = true // show the calendar initially

vm.loadCalendarEvents() // some async loader then(function() { vm.showCal = false; // hide the calendar vm.showCal = true; // show the calendar })

gregory-h avatar Aug 14 '16 14:08 gregory-h

@gregory-h solution worked for me here is my code I am using the default demo code from angular ui-calendar

$scope.showCal = false

var init = function() { $timeout(function () { $scope.showCal = false; // hide the calendar $scope.showCal = true; // show the calendar }, 1000); }();

bmakarand2009 avatar Sep 08 '18 06:09 bmakarand2009