[英]FullCalendar delete event with button
我想從確定我正在使用的內容開始我的問題。 我正在使用由Adam Shaw開發的名為FullCalendar的jquery日歷應用程序。
鏈接: arshaw.com/fullcalendar/
我希望能夠添加刪除功能,以便我可以通過單擊每個事件內的刪除按鈕來刪除事件,並發送一個ajax POST告訴mysql數據庫DELETE其中id等於我剛剛刪除的事件的id。 但是,通過整理文檔,我一直無法找到刪除事件的方法,但卻無法單獨處理該事件和mysql數據庫。 如果有人能夠提供幫助,將不勝感激! 提前致謝。
這是我的代碼:
JAVASCRIPT
<script>
var height = "innerHeight" in window
? window.innerHeight
: document.documentElement.offsetHeight;
var newHeight = parseInt(height)-112;
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
allDay : false,
slotMinutes: <?php echo $tee_inc; ?>,
minTime: "<?php echo $tee_open; ?>",
maxTime: "<?php echo $tee_close; ?>",
height: newHeight,
disableDragging: true,
disableResizing: true,
defaultView: 'agendaDay',
editable: true,
events: [
<?php
$i=-1;
foreach( $tee_time_start as $tts ) {
$i++;
echo '{'; echo "\n";
echo "id : '".$tee_time_id[$i]."',"; echo "\n";
echo "title : '".$tee_first_name[$i]." ".$tee_last_name[$i]." -- ".$tee_holes[$i]." Holes -- ".$tee_phone_number[$i]." ----- <a href=\"#\" id=\"delete_time_".$tee_time_id[$i]."\">Delete</a> ',"; echo "\n";
echo "start : '".$tee_time_start[$i]."',"; echo "\n";
echo "end : '".$tee_time_end[$i]."',"; echo "\n";
echo 'allDay : false'; echo "\n";
echo '},'; echo "\n";
}
?>
],
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days\n' +
'(should probably update your database"+delta+")');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
},
});
});
</script>
您可以使用eventClick
函數。 點擊抓取事件ID,可能會顯示一個對話框並提供刪除按鈕。
eventClick: function(calEvent, jsEvent, view) {
id= calEvent.id;
$( "#dialog" ).dialog({
resizable: false,
height:100,
width:500,
modal: true,
title: 'Want you want to do?',
buttons: {
CLOSE: function() {
$("#dialog").dialog( "close" );
},
"DELETE": function() {
//do the ajax request?
}
}
});
},
比在<body>
標簽中為對話框寫這個
<div id="dialog" title="" style="display:none;">Are you sure want to delete it?</div>
也許使用的jquery的版本是舊的,我不是它的結果,所以我下載更新版本的jquery然后它工作
如果您為事件設置了唯一ID,則可以單獨刪除它們:
Link:
jsFiddle示例
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.