我有以下代码:
<script type="text/javascript">
var Calendar = function() {
return {
//main function to initiate the module
init: function() {
Calendar.initCalendar();
},
initCalendar: function() {
if (!jQuery().fullCalendar) {
return;
}
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var h = {};
if (Metronic.isRTL()) {
if ($('#calendar').parents(".portlet").width() <= 720) {
$('#calendar').addClass("mobile");
h = {
right: 'title',
center: '',
left: 'month'
};
} else {
$('#calendar').removeClass("mobile");
h = {
right: 'title',
center: '',
left: 'month'
};
}
} else {
if ($('#calendar').parents(".portlet").width() <= 720) {
$('#calendar').addClass("mobile");
h = {
left: 'title',
center: '',
right: 'month'
};
} else {
$('#calendar').removeClass("mobile");
h = {
left: 'title',
center: '',
right: 'month'
};
}
}
$('#calendar').fullCalendar('destroy'); // destroy the calendar
$('#calendar').fullCalendar({ //re-initialize the calendar
header: h,
lang: 'es',
defaultView: 'month', // change default view with available options from http://arshaw.com/fullcalendar/docs/views/Available_Views/
slotMinutes: 15,
editable: false,
droppable: false, // this allows things to be dropped onto the calendar !!!
eventClick: function(event, jsEvent, view) {
$('#modalTitle').html(event.title);
$('#modalBody').html(moment(event.start).format('MMM Do YY'));
$('#fullCalModal').modal();
},
drop: function(date, allDay) { // this function is called when something is dropped
// retrieve the dropped element's stored Event Object
var originalEventObject = $(this).data('eventObject');
// we need to copy it, so that multiple events don't have a reference to the same object
var copiedEventObject = $.extend({}, originalEventObject);
// assign it the date that was reported
copiedEventObject.start = date;
copiedEventObject.allDay = allDay;
copiedEventObject.className = $(this).attr("data-class");
// render the event on the calendar
// the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
// is the "remove after drop" checkbox checked?
if ($('#drop-remove').is(':checked')) {
// if so, remove the element from the "Draggable Events" list
$(this).remove();
}
},
<?php planes_para_calendario_yo(); ?>
});
}
};
}();
</script>
我的php功能如下:
function planes_para_calendario_yo(){
$db=new Database;
$q=$db->query("SELECT * FROM planes WHERE coachee='".$_SESSION['duxCoach']."'");
##
$cols=mysql_num_rows($q);
if($cols>0){
echo 'events: [{';
##
$i=1;
while($r=mysql_fetch_array($q)){
$ix=$i++;
if($ix==$cols){
$divisor='}]';
}else{
$divisor='},{';
}
$fecha=$r['fecha'];
$fecha_explode=explode("-",$fecha);
$fecha_jquery=$fecha_explode[1]-1;
echo "
title: 'Sesión ".$r['id']."',
start: new Date(".$fecha_explode[2].", ".$fecha_jquery.", ".$fecha_explode[0]."),
backgroundColor: Metronic.getBrandColor('red'),
allDay: false,
".$divisor;
}
}
}
我想在模态中加入一些自定义参数,例如时间(从我的表中重新作为$ r ['hora']和记录$ r ['id']的id
我怎么能得到它? 谢谢你的帮助。