jQuery Calendar : how to add clickable events on particular dates?

前端 未结 2 713
Happy的楠姐
Happy的楠姐 2021-01-25 01:39

I am using jquery full calendar http://arshaw.com/fullcalendar to display the meetings .

I just want to confirm it that it is possible to add an event(Let\'s a create

2条回答
  •  自闭症患者
    2021-01-25 02:39

    I've used fullcalendar extensively and yes, adding events on specific dates is a core feature of it. You'll need to understand the event object structure(see http://arshaw.com/fullcalendar/docs/event_data/Event_Object/) specifically you set the start to the unix timestamp of the start date/time and either mark it as an all day event allDay = "true" or set end timestamp.

    As you mentioned Ajax, one way to populate the calendar with events is to load them via JSON which you can do like this:

    $('#calendar').fullCalendar({ events: '/myfeed.php' });

    With myfeed.php returning a json structure full of the event objects.


    Here's a full example of how to setup the calendar with various options

    //Initialise the calendar
    $('#calendar').fullCalendar({
        header: { left: 'title', center: '', right: 'today agendaDay,agendaWeek,month prev,next'},
        editable: true,
        showTime: true,
        allDayDefault: false,
        defaultView: 'agendaDay',
        firstHour: 8,
        eventColor: '#23478A',
        eventBorderColor:'#000000',
        eventTextColor:'#ffffff',
        //eventBackgroundColor:,
        theme: true, //enables jquery UI theme
    
        eventSources: [
            '/myfeed.php'
        ],
    
        //this is when the event is dragged and dropped somewhere else 
        eventDrop: function(event,dayDelta,minuteDelta,allDay,revertFunc) 
        {
            //do something...
        },
    
        //this is when event is resized in day/week view
        eventResize: function(event,dayDelta,minuteDelta,revertFunc) 
        {
            //do something
        },
    
        eventClick: function(calEvent, jsEvent, view) 
        {          
            //do something
        },
    
        eventRender: function( event, element, view ) 
        { 
            //redo the title to include the description
            element.find(".fc-event-title").html(event.title + ": " + event.description + "");
        },
    
        loading: function(bool) 
        {
            if (bool)
            {
                $("#loading").show();
            }
            else 
            {
                $('#loading').hide();
            }
        }
    });
    

提交回复
热议问题