gpt4 book ai didi

javascript - 通过onclick全日历发送参数

转载 作者:行者123 更新时间:2023-12-03 12:24:40 25 4
gpt4 key购买 nike

我正在使用完整日历。它运行良好。但我在通过 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(start, end, allDay),而是使用 eventClick: function(event)。然后使用 event.start、event.end、event.allDay 访问变量。然后您需要做的就是将它们与您的查询相匹配。

这是因为 eventClick 不采用 start、end 或 allDay 参数,而是采用事件、jsEvent 或 View 参数。来源:Official Documentation

关于javascript - 通过onclick全日历发送参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24266971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com