Thinkphp+mysql+fullcalendar Calendar drag and data save

Source: Internet
Author: User

Fullcalendar provides a way to drag schedule events, but you must rely on the draggable plug-ins of the jquery UI. After dragging, in the EventDrop callback function, we use post to send AJAX requests to the background PHP with the requested parameter including ID: The ID of the current drag event uniquely identifies, Daydiff: The number of days before and after the drag (days offset), Minudiff: Minute change before and after dragging (minute offset), Allday: Whether it is a whole day event. Then receive the results of the background PHP processing, if the return is not 1 (drag processing failed), pop-up prompts, and the schedule event to revert to the State before the drag.
HTML code:
<div class= "Container" >
<div class= "Demo" >
<div id= ' Calendar ' ></div>
</div>
</div>
<script type= "Text/javascript" src= "/public/js/jquery.js" ></script>
<script src= '/public/js/jquery-ui.js ' ></script>
<script src= '/public/js/fullcalendar.min.js ' ></script>
<script src= '/public/js/jquery.fancybox-1.3.1.pack.js ' ></script>
<script type= "Text/javascript" >
$ (function () {
$ (' #calendar '). Fullcalendar ({
Header: {
Left: ' Prev,next today ',
Center: ' title ',
Right: ' Month,agendaweek,agendaday '
},
Editable:true,
Dragopacity: {
Agenda:. 5,
':. 6
},
Eventdrop:function (event, Daydelta, Minutedelta, AllDay, Revertfunc) {
$.post ("{: U (' Ajax/index ')}?action=drag", {id:event.id, Daydiff:daydelta, Minudiff:minutedelta, Allday:allday}, Function (msg) {
if (msg!= 1) {
Alert (msg);
Revertfunc ();
}
});
},
Eventresize:function (event, Daydelta, Minutedelta, Revertfunc) {
$.post ("{: U (' Ajax/index ')}?action=resize", {id:event.id, Daydiff:daydelta, Minudiff:minutedelta}, Function (msg) {
if (msg!= 1) {
Alert (msg);
Revertfunc ();
}
});
},
Selectable:true,
Select:function (StartDate, EndDate, AllDay, jsevent, view) {
var start = $.fullcalendar.formatdate (StartDate, ' yyyy-mm-dd ');
var end = $.fullcalendar.formatdate (EndDate, ' yyyy-mm-dd ');
$.fancybox ({
' type ': ' Ajax ',
' href ': ' {: U (' Even/index ')}?action=add&date= ' + start + ' &end= ' + END
});
},
Events: ' {: U (' Json/index ')} ',
Dayclick:function (date, AllDay, jsevent, view) {
var seldate = $.fullcalendar.formatdate (date, ' yyyy-mm-dd ');
$.fancybox ({
' type ': ' Ajax ',
' href ': ' {: U (' Even/index ')}?action=add&date=2015-05-07 '
});
},
Eventclick:function (Calevent, jsevent, view) {
$.fancybox ({
' type ': ' Ajax ',
' href ': ' {: U (' Even/index ')}?action=edit&id= ' + calevent.id
});
}
});
});
</script>
Because the code too much will not be posted to click the link below to download the code and database.
Http://pan.baidu.com/s/1kUgki8J
Official Document Address: http://arshaw.com/fullcalendar/docs/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.