我正在使用fullcalendar。我可以选择制作新活动或编辑活动。这将打开一个对话框,您可以在其中编辑数据并将其发布到数据库中。目前我正在开发一个可拖动的事件功能,但当我将它拖入日历时,它不存储在数据库中。
Fullcalendarextern.js(可拖动事件的部分):
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#external-events div.external-event').each(function() {
var eventObject = {
title: $.trim($(this).text())
};
$(this).data('eventObject', eventObject);
$(this).draggable({
zIndex: 999,
revert: true,
revertDuration: 0
});
});
var calendar = $('#calendar').fullCalendar({
editable: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
events: "../testcalendar/fullcalendar/events.php",
droppable: true,
drop: function(date, allDay) {
var originalEventObject = $(this).data('eventObject');
var copiedEventObject = $.extend({}, originalEventObject);
copiedEventObject.start = date;
copiedEventObject.allDay = allDay;
$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
if ($('#drop-remove').is(':checked')) {
$(this).remove();
}
alert(date + ' was moved ' + allDay + ' days\n' +
'(should probably update your database)');
},
});
html文件(可拖动部分):
<div id='calendar'></div>
<table class="displaylegenda" >
<thead>
<tr>
Kleur 状态
colortag;?&gt;“中&GT; soort;?&GT; 可拖动的事件 colortag;?&gt;“中&GT; soort;?&GT; 掉落后移除events.php: 查询($ requete)或死(print_r($ bdd-&gt; errorInfo())); //将编码结果发送到成功页面 echo json_encode($ resultat-&gt; fetchAll(PDO :: FETCH_ASSOC)); ?&GT;
process.php(目前仅用于新事件对话框):
<?php
//include db configuration file
include 'connection.php';
function user_joined($user_werknemer,$user_project,$user_klant,$user_taak,$user_name,$user_desc, $user_start, $user_end, $user_color){
$q = "INSERT INTO evenement (id,idWerknemer,idProject,idKlant,idTaak,title,description,start,end,color) VALUES
('','".$user_werknemer."','".$user_project."','".$user_klant."','".$user_taak."','".$user_name."','".$user_desc."','".$user_start."','".$user_end."','".$user_color."')";
$qo = "INSERT INTO evenementontvanger (idWerknemer,idProject,idEvent,idKlant,idTaak) VALUES ('".$user_werknemer."','".$user_project."','','".$user_klant."','".$user_taak."')";
mysql_query($q);
mysql_query($qo);}
if(isset($_POST['user_werknemer'],$_POST['user_project'],$_POST['user_klant'],$_POST['user_taak'],$_POST['user_name'],$_POST['user_desc'],$_POST['user_start'],$_POST['user_starttime'],$_POST['user_endtime'],$_POST['user_end'],$_POST['user_color'],$_POST['action'])){
$user_werknemer=$_POST['user_werknemer'];
$user_color=$_POST['user_color'];
$user_name=$_POST['user_name'];
$user_desc=$_POST['user_desc'];
$user_project=$_POST['user_project'];
$user_klant=$_POST['user_klant'];
$user_taak=$_POST['user_taak'];
$user_start=$_POST['user_start']." ".$_POST['user_starttime'];
$user_end=$_POST['user_end']." ".$_POST['user_endtime'];
$action=$_POST['action'];
if ($action=='joined'){
user_joined( $user_werknemer, $user_project, $user_klant, $user_taak, $user_name, $user_desc, $user_start, $user_end, $user_color);
}
}
/*if ( (isset($_POST["id"]) && strlen($_POST["id"]) >= 3 && strlen($_POST["id"]) <= 60) &&
(isset($_POST["name"]) && strlen($_POST["name"]) >= 3 && strlen($_POST["name"]) <= 50) &&
(isset($_POST["age"]) && strlen($_POST["age"]) >= 3 && strlen($_POST["age"]) <= 40) )
{ //check $_POST["name"] and $_POST["address"] and $_POST["city"] are not empty
$id = $_POST["id"];
$name = $_POST["name"];
$age = $_POST["age"];
$q = "INSERT INTO tbltest ( id, name, age) VALUES
('".$id."','".$name."','".$age."')";
mysql_query($q);
}*/
?>
答案 0 :(得分:0)
我不熟悉fullcalendar,但我认为你可以在drop函数中发出ajax请求。
例如:
$.post(url: "update.php",{data you need to update});
我认为这些问题也可以帮到你:
How to send an ajax request to update event in FullCalender UI, when eventDrop is called?