2013-04-25 105 views
0

我創建了一個保存到MySQL的日曆。fullCalendar全部顯示爲allDay

我將allDay值設置爲時間幀事件的false,但日曆將其顯示爲整天。

這得到了事件..

$sql = mysql_query('SELECT * FROM `companies`.`calendar`'); 
${'Events'} = array(); 
while(${'Event'} = mysql_fetch_assoc($sql)){ 
    ${'Events'}[] = ${'Event'}; 
} 

快照我的表:

這裏是我的jQuery

$(document).ready(function() { 

    $('#eventToAdd').dialog({ 
     autoOpen: false, 
     height: '300', 
     width: '550', 
     modal: true, 
     resizable: false, 
     position: 'center', 
    }); 

    var date = new Date(); 
    var d = date.getDate(); 
    var m = date.getMonth(); 
    var y = date.getFullYear(); 

    var calendar = $('#calendar').fullCalendar({ 
     theme: true, 
     header: { 
      left: 'prev,next today', 
      center: 'title', 
      right: 'month,agendaWeek,agendaDay' 
     }, 
     loading: function(bool) { 
      if (bool) $('#loading').show(); 
      else $('#loading').hide(); 
     }, 
     eventClick: function(calEvent, jsEvent, view) { 
      $('#eventTitle').val(calEvent.title); 
      $('#textColor').val(calEvent.textColor); 
      $('#backgroundColor').val(calEvent.color); 
      $("#eventToAdd").dialog({ 
       autoOpen: true, 
       title: "Update Event", 
       modal: true, 
       buttons: [ 
       { 
        text:"Update Event", 
        click: function() { 
         if($('#eventTitle').val()){ 
           calEvent.title = $('#eventTitle').val(); 
           calEvent.color = $('#backgroundColor').val(); 
           calEvent.textColor = $('#textColor').val(); 
           calendar.fullCalendar('updateEvent',calEvent); 
           $.post('post.api.php', { 'api': 'updateEvent', 'id': calEvent.id, 'title': calEvent.title, 'start': $.fullCalendar.formatDate(calEvent.start, 'yyyy-MM-dd h:mm:ss tt'), 'end': $.fullCalendar.formatDate(calEvent.end, 'yyyy-MM-dd h:mm:ss tt'), 'allDay': calEvent.allDay, 'bgColor': calEvent.color, 'textColor': calEvent.textColor }, function(resp) { 
            if(resp == 'SUCCESS') { 
             jAlert('The event has been updated','Updated'); 
            } else { 
             jAlert('There was an error updating the event<br />Please try again later.<br />ERROR CODE: 728375', 'Process Error'); 
            } 
            $('#eventToAdd').dialog('close'); 
           }); 
         } 
        } 
       }, 
       { 
        text: "Cancel", 
        click: function() { $(this).dialog('close'); } 
       }] 
      }); 
     }, 
     selectable: true, 
     selectHelper: true, 
     select: function (start, end, allDay, jsEvent, view) { 
      $("#eventToAdd").dialog(
      { 
       autoOpen: true, 
       title: "Create Event", 
       modal: true, 
       buttons: [ 
       { 
        text:"Create Event", 
        click: function() { 
         if($('#eventTitle').val()){ 
          calendar.fullCalendar('renderEvent', 
          { 
           title: $('#eventTitle').val(), 
           start: $.fullCalendar.formatDate(start, 'yyyy-MM-dd h:mm:ss tt'), 
           end: $.fullCalendar.formatDate(end, 'yyyy-MM-dd h:mm:ss tt'), 
           allDay: allDay, 
           textColor: $('#textColor').val(), 
           color: $('#backgroundColor').val() 
          }, 
          true 
         ); 
         var startDate = $.fullCalendar.formatDate(start, 'yyyy-MM-dd h:mm:ss tt'); 
         var endDate = $.fullCalendar.formatDate(end, 'yyyy-MM-dd h:mm:ss tt'); 
         $.post('post.api.php', { 'api': 'createEvent', 'title': $('#eventTitle').val(), 'start': startDate, 'end': endDate, 'allDay': allDay, 'textColor': $('#textColor').val(), 'bgColor': $('#backgroundColor').val() }, function(response) { 
          if(response == 'SUCCESS'){ 
           jAlert('The event has been saved!','Event Created'); 
          } else { 
           jAlert('There was an error saving your event<br />Please try again later or let JD know<br />ERROR CODE: 882293','Process Error'); 
          } 
         }); 
         } 
         $(this).dialog('close'); 
        } 
       }, 
       { 
        text: "Cancel", 
        click: function() { $(this).dialog('close'); } 
       } 
       ], 
       close: function(){ 
        $('#eventTitle').val(''); 
        $('#textColor').val(''); 
        $('#backgroundColor').val('');  
       } 
      }); 
     }, 
     editable: true, 
     events: <?= ${'Events'}; ?> 

    }); 


}); 
+0

你確定allDay設置爲false,而不是'假'(即字符串)?此外,如果什麼都不會allDay你可以使用[allDayDefault](http://arshaw.com/fullcalendar/docs/event_data/allDayDefault/) – tocallaghan 2013-04-26 04:58:36

+0

你可以用$ {'Events'}數組更新你的問題嗎? – 2013-04-26 07:12:26

+0

即時通訊是一個白癡......這是遲到..哈哈..它是一個字符串不是布爾 – odie2828 2013-04-26 16:11:31

回答

0

的記錄值應返回假(不含引號);不是「假」。我有同樣的問題,並應用這個簡單的解決方案:

// ----------------------- 
while ($row = mysql_fetch_assoc($sql)) { 
// ----------------------- 
if ($row['event_allday'] = 'false') { 
$allDayStatus = false; 
} 
// ----------------------- 
$eventsArray['id'] = $row['event_id']; 
$eventsArray['title'] = $row['event_title']; 
$eventsArray['start'] = $row['event_start']; 
$eventsArray['end'] = $row['event_end']; 
$eventsArray['url'] = $row['event_url']; 
$eventsArray['allDay'] = $allDayStatus; 
$eventsArray['className'] = $row['event_class']; 
$eventsArray['admNotes'] = $row['event_adm_notes']; 
// -----------------------