0

我创建了一个保存到 MySQL 的日历。

我将时间范围事件的 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'}; ?>

    });


});
4

1 回答 1

0

记录值应返回为 false(不带引号);不是“假的”。我遇到了同样的问题并应用了这个简单的解决方案:

// -----------------------
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'];
// -----------------------
于 2013-11-27T13:12:48.587 回答