MySQL に保存するカレンダーを作成しました。
時間枠イベントの allDay 値を false に設定していますが、カレンダーには終日として表示されます。
これはイベントを取得します..
$sql = mysql_query('SELECT * FROM `companies`.`calendar`');
${'Events'} = array();
while(${'Event'} = mysql_fetch_assoc($sql)){
${'Events'}[] = ${'Event'};
}
私のテーブルのスナップショット:
ここに私のjQueryがあります
$(document).ready(function() {
$('#eventToAdd').dialog({
autoOpen: false,
height: '300',
width: '550',
modal: true,
resizable: false,
position: 'center',
});
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
},
eventClick: function(calEvent, jsEvent, view) {
$('#eventTitle').val(calEvent.title);
$('#textColor').val(calEvent.textColor);
$('#backgroundColor').val(calEvent.color);
$("#eventToAdd").dialog({
autoOpen: true,
title: "Update Event",
modal: true,
buttons: [
{
text:"Update Event",
click: function () {
if($('#eventTitle').val()){
calEvent.title = $('#eventTitle').val();
calEvent.color = $('#backgroundColor').val();
calEvent.textColor = $('#textColor').val();
calendar.fullCalendar('updateEvent',calEvent);
$.post('post.api.php', { 'api': 'updateEvent', 'id': calEvent.id, 'title': calEvent.title, 'start': $.fullCalendar.formatDate(calEvent.start, 'yyyy-MM-dd h:mm:ss tt'), 'end': $.fullCalendar.formatDate(calEvent.end, 'yyyy-MM-dd h:mm:ss tt'), 'allDay': calEvent.allDay, 'bgColor': calEvent.color, 'textColor': calEvent.textColor }, function(resp) {
if(resp == 'SUCCESS') {
jAlert('The event has been updated','Updated');
} else {
jAlert('There was an error updating the event<br />Please try again later.<br />ERROR CODE: 728375', 'Process Error');
}
$('#eventToAdd').dialog('close');
});
}
}
},
{
text: "Cancel",
click: function() { $(this).dialog('close'); }
}]
});
},
selectable: true,
selectHelper: true,
select: function (start, end, allDay, jsEvent, view) {
$("#eventToAdd").dialog(
{
autoOpen: true,
title: "Create Event",
modal: true,
buttons: [
{
text:"Create Event",
click: function () {
if($('#eventTitle').val()){
calendar.fullCalendar('renderEvent',
{
title: $('#eventTitle').val(),
start: $.fullCalendar.formatDate(start, 'yyyy-MM-dd h:mm:ss tt'),
end: $.fullCalendar.formatDate(end, 'yyyy-MM-dd h:mm:ss tt'),
allDay: allDay,
textColor: $('#textColor').val(),
color: $('#backgroundColor').val()
},
true
);
var startDate = $.fullCalendar.formatDate(start, 'yyyy-MM-dd h:mm:ss tt');
var endDate = $.fullCalendar.formatDate(end, 'yyyy-MM-dd h:mm:ss tt');
$.post('post.api.php', { 'api': 'createEvent', 'title': $('#eventTitle').val(), 'start': startDate, 'end': endDate, 'allDay': allDay, 'textColor': $('#textColor').val(), 'bgColor': $('#backgroundColor').val() }, function(response) {
if(response == 'SUCCESS'){
jAlert('The event has been saved!','Event Created');
} else {
jAlert('There was an error saving your event<br />Please try again later or let JD know<br />ERROR CODE: 882293','Process Error');
}
});
}
$(this).dialog('close');
}
},
{
text: "Cancel",
click: function() { $(this).dialog('close'); }
}
],
close: function(){
$('#eventTitle').val('');
$('#textColor').val('');
$('#backgroundColor').val('');
}
});
},
editable: true,
events: <?= ${'Events'}; ?>
});
});