2016-09-17 51 views
0

fullcalendar中的Dayclick在我的yii2站點中不起作用。我使用了下面的代碼。我無法獲得此代碼的工作。fullcalendar中的dayclick無法正常工作

$(document).ready(function() { 
$('#calendar').fullCalendar({ 

     header: { 
      left: 'prev,next today', 
      center: 'title', 
      right: 'month,agendaWeek,agendaDay' 
     }, 

     ignoreTimezone:true, 
     editable: true, 

     events: $list, 

     className: 'gcal-event', 
     eventClick:function(event){ 
         var x = event.id; 
         document.cookie='id='+x+''; 
         $('#cal-modal').modal('show'); 
         } 
     }); 


     $('#calendar').fullCalendar({ 
     dayClick: function(date, jsEvent, view) { 
       alert('Clicked on: ' + date.format()); 
       $(this).css('background-color', 'red'); 
       } 
     }); 
}); 

請看看我的代碼,並給出建議。

+0

任何錯誤的表現? – momouu

+0

沒有顯示錯誤。 –

+0

是'alert('點擊:'+ date.format());'顯示? – momouu

回答

0

檢查:https://fullcalendar.io/docs/mouse/dayClick/

$('#calendar').fullCalendar({ 
    dayClick: function(date, allDay, jsEvent, view) { 

     if (allDay) { 
      alert('Clicked on the entire day: ' + date); 
     }else{ 
      alert('Clicked on the slot: ' + date); 
     } 

     alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY); 

     alert('Current view: ' + view.name); 

     // change the day's background color just for fun 
     $(this).css('background-color', 'red'); 

    } 
});