php - 全日历事件在 9 点之前不显示

标签 php jquery mysql fullcalendar

到目前为止,我正在使用 jQuery 插件 Fullcalendar 我能够显示存储在我的 MySQL 数据库中的数据,但事实并非如此显示正确的方式。我的意思是:

例如:

}
    "id":"1","title":"Test",
    "start":"2015-01-28 10:30:00",
    "end":"2015-02-04 12:30:00",
    "url":"",
    "allDay":"false"
}

这是我数据库中的一条记录。它应该显示在我的日历上

2015-01-28 10:30:002015-02-04 12:30:00

但事实并非如此。相反,allDaytrue(即使在数据库中它说 false),我也需要添加另一天。

例如:如果我想显示从 16-03 到 17-03 的日期,我需要添加另一天 -> 16-03 到 18-03(以便显示 16-03 到 17-03) .

我的意思是,当我在 9 点之后记录时,事件“框”或 div 会延伸到正确的日期。否则它不会延伸到正确的日期。

但默认情况下 businessHoursfalse。 (我什至添加了:businessHours: false)但没有成功。

这是我的SELECT 查询:

<?php
$json = array();

// Query that retrieves events
$querySQL = "SELECT * FROM evenement";
// connection to the database
try {
    $bdd = new PDO("mysql:host=localhost;dbname=dbcontrol", "root", "");
} catch(Exception $e) {
    exit('Unable to connect to database.');
}
// Execute the query
$result = $bdd->query($querySQL) or die(print_r($bdd->errorInfo()));

// sending the encoded result to success page
    echo json_encode($result->fetchAll(PDO::FETCH_ASSOC));
?>

这是我的 jQuery:

$(document).ready(function() {
    var currentTime = new Date();
        /* initialize the external events
        -----------------------------------------------------------------*/

        $('#external-events .fc-event').each(function() {

            // store data so the calendar knows to render an event upon drop
            $(this).data('event', {
                title: $.trim($(this).text()), // use the element's text as the event title
                stick: true // maintain when user navigates (see docs on the renderEvent method)
            });

            // make the event draggable using jQuery UI
            $(this).draggable({
                zIndex: 999,
                revert: true,      // will cause the event to go back to its
                revertDuration: 0  //  original position after the drag
            });

        });


        /* initialize the calendar
        -----------------------------------------------------------------*/

        $('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
            defaultDate: currentTime,
            editable: true,
            droppable: true,

            eventBackgroundColor: '#A80000',
            eventBorderColor: '#A80000',

            eventLimit: true, // allow "more" link when too many events
            events: {
                url: './php/select-events.php',
                error: function() {
                    $('#script-warning').show();
                }
            },
            loading: function(bool) {
                $('#loading').toggle(bool);
            }
        });

    });

最佳答案

问题 -> "allDay":"false"

allDay 应该有一个 bool 值,而不是字符串“false”。将其更改为 "allDay":false 将使其正常工作。

关于php - 全日历事件在 9 点之前不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28208694/

相关文章:

javascript - Google 公共(public)日历链接不起作用(完整日历)

jquery - 箱子换号? (jQuery)

javascript - 如何将 css 文件添加到页面正文?

php - 显示图像 Blob ,可能编码错误

php - 如果多个准备好的语句之一失败,则停止并恢复

php - 古吉拉特语字体无法从 mysql 数据库正确显示

php - PDO php 中的一些查询正在执行,有些则没有

mysql匹配选择像主题标签,没有全文

javascript - jQuery .ajax 阻塞 .getJSON?

php - Mysql数据将在表列中显示 "Array"