通过点击完整日历发送参数



我使用完整的日历。它工作得很好。但我有问题通过onclick事件发送参数。这里是js:

<script>
$(document).ready(function() {
    $('#calendar').fullCalendar({
                    theme: true,
                    header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        editable: false,
                    minTime: 8,
                    maxTime: 21,
                    weekMode: 'liquid',
                    eventClick: function(start, end, allDay) { // Get the start, end, allday when one event slot is clicked
                            $('#time').val(start); // Set an hidden field with start value (String or Timestamp)
                            $('#hiddenEnd').val(end); // Set another hidden field with end value (String or Timestamp)
                            $('#hiddenAllDay').val(allDay); // Set another hidden field with allDay value (true or false)
                    },
        events: "<?php echo Yii::app()->request->baseUrl; ?>/index.php/aula/calend/<?php echo $id; ?>",
                    eventRender: function (event, element) {
                        element.attr('href', 'javascript:void(0);');
                        element.attr('onclick', 'openModal("' + event.title + '","' + event.description + '","' + event.start + '");');
                    },
        eventDrop: function(event, delta) {
            alert(event.title + ' foi movido ' + delta + ' dia(s)n' +
                '(Esta acao nao altera o banco de dados!)');
        },
        loading: function(bool) {
            if (bool) $('#loading').show();
            else $('#loading').hide();
        }
    });

});
    function openModal(title, info, start) {
        $("#eventInfo").html(info);
        $("#start-time").val(start);
        //var dd = start;
        $("#add-event").dialog({ modal: true, title: title, width:550,
        buttons: {
            "Salvar": function() {
                $.ajax({
                    type:"POST",
                    url: "<?php echo Yii::app()->request->baseUrl; ?>/index.php/aula/marcacao",
                    data: $('#add-event-form').serialize(),
                    success: function(){
                        $('#calendar').fullCalendar('refetchEvents');
                    }
                });
                $(this).dialog("close");
            },
            Cancel: function() {
                $(this).dialog("close");
            }
        },});
    };

当我点击一个事件时,我需要将该事件的小时发送给php,因为我需要在我的查询中使用它,然后使用这个表单打开对话框:

<form action="" id ="add-event-form" name="add-event-form">
       <?php query = "SELECT aula FROM cursos WHERE hour = ****Hour clicked on calendar**** ?>
       <label for="title">Event Name</label>
    <input type="text" name="title" id="title"/>
    <p>
    <label for="add-date">Date</label>
    <input type="text" name="event-date" id="event-date" tabindex="-1" />
    </p>
    <p>
    <label for="add-start-time">Start Time</label>
    <input type="text" name="start-time" id="start-time" value=""/>
    </p>
    <p>
    <label for="add-end-time">End Time</label>
    <input type="text" name="end-time" id="end-time" />
    </p>
</form>

我已经尝试解决这个问题好几天了,但没有成功。有人能帮帮我吗?

用eventClick: function(event)代替eventClick: function(start, end, allDay)。然后使用事件访问变量。首先,事件。最终,event.allDay。你所需要做的就是将它们与你的查询进行匹配。

这是因为eventClick不接受start, end或allDay参数,而是一个事件,jsEvent或视图参数。来源:官方文档

在服务器端使用$_POST['start-time']检索参数

$start = htmlspecialchars($_POST['start-time']);
$query = "SELECT aula FROM cursos WHERE hour =". $start;

相关内容

  • 没有找到相关文章

最新更新