2012-02-20 5 views
1

В настоящее время я работаю над проектом, включая плагин Jcalery fullcalendar. Я хочу создать список со всеми событиями (с дополнительной информацией) за выбранный день, щелкнув по дневному заголовку в повестке дняWeek- или повестки дня. Я привязал событие щелчка на заголовке таблицы через viewDisplay Опция:FullCalender: связать событие click с заголовком таблицы

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....  
      }); 
     } 
    }); 
} 

Это прекрасно работает ... но как продолжить оттуда? Единственное, что я могу получить, это дневной заголовок (например, «Солнце 2/19»). Возможно, есть гораздо более легкое решение?

Спасибо за помощь!

ответ

2

Я решил, изменив columnFormat of weekView, чтобы прочитать полную дату. В моем случае для каталонской местности:

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

Тогда на viewDisplay вы можете разобрать полную дату и перейти к agendaDay по щелкнули дату:

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

Попробуйте обходной путь я сделал сам. Это сделает навигацию с повестки дня. Откройте для себя повестку дня. Легко щелкнув по дневным заголовкам, просто вызовите zumaMaker() после 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(); 
} 

Также вы можете добавить этот css для настройки дневных заголовков при наведении указателя.

.fc-day-header:hover { 
    background-color: orange; 
} 
.fc-day-header { 
    background-color: white; 
} 
Смежные вопросы