1
votes

I'm currently working on a project including the fullcalendar JQuery Plugin. I want to create a list with all events (with additional information) of selected day by clicking on the day-caption in agendaWeek- or agendaDay. I bound a click event to the table header through the viewDisplay Option:

viewDisplay: function(view){
    $('table.fc-agenda-days thead th').each(function(){
        if($(this).html() != " "){ 
            $(this).css('cursor','pointer'); // set cursor
            $(this).unbind('click'); //unbind previously bound 'click'
            $(this).click(function(){
                // to be continued....       
            });
       }
    });
}

This works fine... but how to continue from there? The only thing I can retrieve is the day-caption (e.g. "Sun 2/19"). Perhaps there is a much easier solution?

2

2 Answers

2
votes

I solved by changing the columnFormat of weekView to read the full date. In my case for catalan locale:

columnFormat: {
        month: 'ddd',
        week: 'dddd dd/MM/yyyy',
        day: 'dddd dd/MM/yyyy'
    }

Then on viewDisplay you can parse the full date and navigate to agendaDay on clicked date:

viewDisplay: function(view) {
        // Add onclick to header columns of weekView to navigate to clicked day on dayView
        $('table.fc-agenda-days thead th').each(function(){
            if($(this).html() != " "){
                $(this).css('cursor','pointer'); // set cursor
                $(this).unbind('click'); //unbind previously bound 'click'
                $(this).click(function(){
                    var dateStr = $(this).html().substring($(this).html().indexOf(' ')+1);
                    var day = dateStr.substring(0, 2);
                    var month = dateStr.substring(3, 5) - 1;
                    var year = dateStr.substring(6, 10);
                    $('#calendar').fullCalendar('gotoDate', new Date(year, month, day));
                    $('#calendar').fullCalendar('changeView', 'agendaDay');
                });
            }
        });
    }
0
votes

Try this workaround i made myself. It will make navigation from agendaWeek to agendaDay easy by clicking on day headers just call zumaMaker() after fullcalendar init.

function zumaMaker() {

 var arrayUIDays = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
 for (var m = 0; m < arrayUIDays.length; m++) {
    var dim = ".fc-day-header.fc-widget-header.fc-" + arrayUIDays[m];
    var dok = $(dim).html();
    $(dim).attr("onclick", "zumaMethod( '" + dok + "','" + dim + "');");
    $(dim).css("cursor", "pointer");
    }
}

function zumaMethod(doma, diver) {

  var date = doma.split(" ")[1].split("/");
  var day = date[0];
  var month = date[1];
  var year = date[2];
  var off_date = year + "-" + month + "-" + day + "T" + "00:00:00";

  $("#pl_tbl").fullCalendar('changeView', 'agendaDay');
  $("#pl_tbl").fullCalendar('gotoDate', off_date);
  $(diver).css("cursor", "pointer");
  $(diver).attr("onclick", "zumaMethodRevert();");
}

function zumaMethodRevert() {
  $("#pl_tbl").fullCalendar('changeView', 'agendaWeek');
  zumaMaker();
}

Also you can add this css to customize the day headers on hover.

.fc-day-header:hover {
   background-color: orange;
}
.fc-day-header {
   background-color: white;
}