1

I'm using FullCalendar by Adam Shaw.

To show all events on a day, I'm using the listday-view. I need to show a link in the header of the table.

I tried the following code, but it doesn't work.

viewRender: function (view, element) {  
    if(view.name === 'listDay') {
        element.find('.fc-widget-header').append( '<span>&raquo; My Text</span>' );
    }
}

It seems, that the element is not been found. A "jQuery-alert" instead of the "element.find" works.

FabioBranch
  • 175
  • 4
  • 19
The Wro
  • 13
  • 1
  • 7
  • The docs for this event say "This callback will trigger after the view has been fully rendered". So in theory your code ought to work. `element` does appear to contain all those sub elements including the one you're targeting. Stumped me, as well :-|. – ADyson Mar 07 '17 at 10:48

1 Answers1

2

That's because the viewRender callback runs before the .fc-widget-header element has been rendered and can't be found. https://fullcalendar.io/docs/display/viewRender/

You can add your code in the eventAfterAllRender callback because as i can see the listDay will rendered only if there are events to show.

example

eventAfterAllRender : function (view) {  
    if(view.name === 'listDay') {
        view.el.find('.fc-widget-header').append( '<span>&raquo; My Text</span>' );
    }
}
todes
  • 346
  • 1
  • 6