您可以打开有关dayClick
事件的对话框(http://api.jqueryui.com/dialog/,注意:不包含在 FullCalendar jqueryui 源文件中)。向此对话框添加组合框/选择。使用 ajax / json ( http://api.jquery.com/jQuery.getJSON/ ) 获取数据。
在对话框中添加一个按钮并通过其函数添加事件 ( http://arshaw.com/fullcalendar/docs/event_data/addEventSource/ )。
操作选择的有用问题:
注意源包含一些示例。fullcalendar-1.6.1/demos/selectable.html 似乎对解决您的问题很有用。
我使用以下方式创建了一个演示页面:http ://arshaw.com/fullcalendar/docs/usage/
日历.html:
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<link rel='stylesheet' type='text/css' href='fullcalendar-1.6.1/fullcalendar/fullcalendar.css' />
</head>
<body>
<div id="dialog" title="Dialog Title">
<select id="titles"></select>
</div>
<div id='calendar'></div>
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="fullcalendar-1.6.1/fullcalendar/fullcalendar.min.js"></script>
<script type="text/javascript">
//$(document).ready(function() {
// page is now ready, initialize the calendar...
$( "#dialog" ).dialog({ autoOpen: false });
$('#calendar').fullCalendar({
dayClick: function(date, allDay, jsEvent, view) {
$('#titles').find('option').remove(); //remove old options
/* get the titles via json */
$.getJSON('titles.php', function(data) {
$.each(data, function(key, val) {
//$("#titles").append(new Option(val.toString(),key));
/* add the val as key to demo it*/
$("#titles").append(new Option(val.toString(),val.toString()));
});
});
$( "#dialog" ).dialog({buttons: { "Ok": function()
{
/* add the event to the Calendar */
$('#calendar').fullCalendar( 'addEventSource', [{title: $("#titles").val(), start:date}]);
$( this ).dialog( "close" );
}}});
$( "#dialog" ).dialog("open");
}
});
//});
</script>
</body>
</html>
标题.php:
<?php
header('Content-type: application/json');
$rows = array('Title one','Title two','Title three');
echo json_encode((object)$rows);
exit;