Javascript FullCalendar上的动态时隙
我正在尝试建立一个完整日历的在线活动预订系统。我使用与用户绑定的事件/日历,每个用户都有自定义的slotMinutes、minTime和maxTime。这些值从DB中提取并插入到隐藏表单中 为了进行测试,我在php中修复了表单中的值Javascript FullCalendar上的动态时隙,javascript,php,jquery,fullcalendar,Javascript,Php,Jquery,Fullcalendar,我正在尝试建立一个完整日历的在线活动预订系统。我使用与用户绑定的事件/日历,每个用户都有自定义的slotMinutes、minTime和maxTime。这些值从DB中提取并插入到隐藏表单中 为了进行测试,我在php中修复了表单中的值 <div id="practitioner-details hidden"> <form action="" id="practitioner-details"> <input type="hidden" na
<div id="practitioner-details hidden">
<form action="" id="practitioner-details">
<input type="hidden" name="name" value="Dr Demo"/>
<input type="hidden" name="timeslot" value="15"/>
<input type="hidden" name="starthour" value="09"/>
<input type="hidden" name="endhour" value="17"/>
</form>
</div>
无论我使用.val().toString()还是plain.val(),我都会通过警告VAR它正在正确读取它们来知道,但是不管我输入了什么,日历的渲染时间都不会超过1小时。它似乎正确地设置了开始时间,但没有其他设置。如果我硬编码的时间,它的工作计划
如果我试图读取表单中的值,我不知道它为什么会死掉
编辑
某些代码已从$(文档)中删除。准备就绪,可用于计算。特别是事件处理代码。Jquery部分必须更新如下:
$(document).ready(function() {
var timeslot = $('input[name=timeslot]').val().toString();
var starttime = $('input[name=starthour]').val().toString();
var endtime = $('input[name=endhour]').val().toString();
// Activate Current Calendar Link
$('.links #' + $('#practitioner').val()).addClass('active');
var defaultViewCal = 'agendaWeek';
// Set Event Source URL
$('#fullCalendar').attr('events', "/calendar/view/" + $('.links a.active').attr('id'));
// Initiate Full Calendar
$('#fullCalendar').fullCalendar({
header: {
//view names are: month, agendaWeek, agendaDay
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultView: defaultViewCal,
firstDay: 1,
columnFormat: {
month: 'dddd',
week: 'dddd \n dd/MM',
day: 'dddd dd MMM yyyy' },
titleFormat: {
month: 'MMMM yyyy',
week: "dd MMM[ yyyy]{ '—'[ dd] MMM yyyy}",
day: 'dddd dd MMM yyyy' },
//time slot - from practitioner
slotMinutes: timeslot,
allDaySlot: false,
editable: true,
selectable: true,
//starting time (hour) - from practitioner
minTime: starttime,
//closing time (hour) - from practitioner
maxTime: endtime,
//fetch time from practitioner details
lazyFetching: true,
// Set Height to Prevent Scroll Bars in day and week view
viewDisplay: function (view) {
var h;
if (view.name == "month") {
h = NaN;
}
else {
h = 2100;
}
$('#fullCalendar').fullCalendar('option', 'contentHeight', h);
}
});
});
$(document).ready(function() {
var timeslot = $('input[name=timeslot]').val().toString();
var starttime = $('input[name=starthour]').val().toString();
var endtime = $('input[name=endhour]').val().toString();
// Activate Current Calendar Link
$('.links #' + $('#practitioner').val()).addClass('active');
var defaultViewCal = 'agendaWeek';
// Set Event Source URL
$('#fullCalendar').attr('events', "/calendar/view/" + $('.links a.active').attr('id'));
// Initiate Full Calendar
$('#fullCalendar').fullCalendar({
header: {
//view names are: month, agendaWeek, agendaDay
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultView: defaultViewCal,
firstDay: 1,
columnFormat: {
month: 'dddd',
week: 'dddd \n dd/MM',
day: 'dddd dd MMM yyyy' },
titleFormat: {
month: 'MMMM yyyy',
week: "dd MMM[ yyyy]{ '—'[ dd] MMM yyyy}",
day: 'dddd dd MMM yyyy' },
//time slot - from practitioner
slotMinutes: parseInt(timeslot),
allDaySlot: false,
editable: true,
selectable: true,
//starting time (hour) - from practitioner
minTime: parseInt(starttime),
//closing time (hour) - from practitioner
maxTime: parseInt(endtime),
//fetch time from practitioner details
lazyFetching: true,
// Set Height to Prevent Scroll Bars in day and week view
viewDisplay: function (view) {
var h;
if (view.name == "month") {
h = NaN;
}
else {
h = 2100;
}
$('#fullCalendar').fullCalendar('option', 'contentHeight', h);
}
});
});
只是更新:在最新版本V2中,“slotMinutes”更改为“slotDuration”,slotDuration的值可以设置为“00:15:00”,持续15分钟,以此类推。
默认值为:“00:30:00”(30分钟) 关于,
Pravin B