Display more Text in fullcalendar

后端 未结 9 844
一整个雨季
一整个雨季 2020-12-12 09:45

I am looking for a solution to display more information in event.

For example in the DayView you see a event from 06:00 to 10:00.
I want to display a additio

相关标签:
9条回答
  • 2020-12-12 10:11

    This code can help you :

    $(document).ready(function() { 
        $('#calendar').fullCalendar({ 
            events: 
                [ 
                    { 
                        id: 1, 
                        title: 'First Event', 
                        start: ..., 
                        end: ..., 
                        description: 'first description' 
                    }, 
                    { 
                        id: 2, 
                        title: 'Second Event', 
                        start: ..., 
                        end: ..., 
                        description: 'second description'
                    }
                ], 
            eventRender: function(event, element) { 
                element.find('.fc-title').append("<br/>" + event.description); 
            } 
        });
    }   
    
    0 讨论(0)
  • 2020-12-12 10:12

    With the modification of a single line you could alter the fullcalendar.js script to allow a line break and put multiple information on the same line.

    In FullCalendar.js on line ~3922 find htmlEscape(s) function and add .replace(/<br\s?/?>/g, '
    ') to the end of it.

    function htmlEscape(s) {
        return s.replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;')
        .replace(/'/g, '&#039;')
        .replace(/"/g, '&quot;')
        .replace(/\n/g, '<br />')
        .replace(/&lt;br\s?\/?&gt;/g, '<br />');
    }
    

    This will allow you to have multiple lines for the title, separating the information. Example replace the event.title with title: 'All Day Event' + '<br />' + 'Other Description'

    0 讨论(0)
  • 2020-12-12 10:14

    For some reason, I have to use

    element.find('.fc-event-inner').empty();
    

    to make it work, i guess i'm in day view.

    0 讨论(0)
提交回复
热议问题