Jquery 全日历“;“每日议程”;及;weekAgenda“;背景颜色变化
我正在更改每个时段fullcalendar中dayAgenda和weekAgenda的背景色 到目前为止,我已经在viewRender上尝试过了,但是失败了Jquery 全日历“;“每日议程”;及;weekAgenda“;背景颜色变化,jquery,fullcalendar,Jquery,Fullcalendar,我正在更改每个时段fullcalendar中dayAgenda和weekAgenda的背景色 到目前为止,我已经在viewRender上尝试过了,但是失败了 viewRender: function (view, element, cell) { if (view.type == "agendaWeek") { //change the each day background colors in week view vertically var day
viewRender: function (view, element, cell) {
if (view.type == "agendaWeek") {
//change the each day background colors in week view vertically
var dayId = "Day id on which other user has set the holidays"
// Set here the background color of column vartically if there is a holiday
}
if (view.type == "agendaDay") {
//change the each time slot background colors horizontally according to availability of other user
//Other user available between these time.
var startTime = "start time here for that day, set by other user for his avaliability ";
var endTime = "end time here for that day , set by other user for his avaliability";
//Set here the background color if the other user not available at those time.
}
}
如何实现以下目标:
我继续像下面这样做,现在的假期显示与正确的背景颜色在准确的插槽
if (view.type == "agendaWeek") {
//Get data in ajax call
$.each(data, function (i, item) {
var dayClass = data[i].IsHoliday || data[i].IsDayOff == true ? data[i].DayId : "";
if (dayClass != "")
dayClass = dayClass == 1 ? "fc-mon"
: dayClass == 2 ? "fc-tue"
: dayClass == 3 ? "fc-wed"
: dayClass == 4 ? "fc-thu"
: dayClass == 5 ? "fc-fri"
: dayClass == 6 ? "fc-sat"
: "fc-sun";
if (data != undefined)
$(".fc-day." + dayClass).css("background-color", "#CCCCC");
});
}
if (view.type == "agendaDay") {
//Get data in ajax call
//Just color the back ground of each dayAgenda time slot
$('.fc-slats > table > tbody > tr').each(function (i) {
$("td:nth-child(2)", this).css("background", "#CCCCCC");
});
$.each(data, function (i, item) {
// if this day is alredy a holiday or day off then make it
//completely unavialable to book appointment.
if (data[i].IsHoliday == true || data[i].IsDayOff == true) {
return false;
}
var startTime = moment(data[i].StartTime, ["h:mm A"]).format("HH:mm");
var endTime = moment(data[i].EndTime, ["h:mm A"]).format("HH:mm");
var startTimeS = moment.duration(startTime, 'ms').asSeconds();
var endTimeS = moment.duration(endTime, 'ms').asSeconds();
$('.fc-slats > table > tbody > tr').each(function () {
var time = moment(this.innerText.trim(), ["h:mm A"]).format("HH:mm");
var timeS = moment.duration(time, 'ms').asSeconds();
//Remove the color slots which are avialable for the physician.
if (timeS >= startTimeS && timeS <= endTimeS) {
$("td:nth-child(2)", this).css("background", "");
}
});
})
}
if(view.type==“agendaWeek”){
//在ajax调用中获取数据
$。每个(数据、功能(i、项){
var dayClass=data[i]。IsHoliday | | data[i]。IsDayOff==true?data[i]。DayId:“”;
如果(dayClass!=“”)
dayClass=dayClass==1?“fc周一”
:dayClass==2?“fc tue”
:dayClass==3?“fc wed”
:dayClass==4?“fc thu”
:dayClass==5?“fc fri”
:dayClass==6?“fc sat”
:“fc sun”;
如果(数据!=未定义)
$(.fc day.+dayClass).css(“背景色”,“CCCCC”);
});
}
如果(view.type==“agendaDay”){
//在ajax调用中获取数据
//只需给每日议程时段的背景涂上颜色即可
$('.fc板条>表格>主体>tr')。每个(功能(i){
$(“td:nth child(2)”,this).css(“背景”,#cccc”);
});
$。每个(数据、功能(i、项){
//如果这一天一直是假日或休息日,那么就定下来吧
//完全无法预约。
如果(数据[i].IsHoliday==true | |数据[i].IsDayOff==true){
返回false;
}
var startTime=力矩(数据[i]。startTime,[“h:mm A”]).format(“HH:mm”);
var-endTime=moment(数据[i].endTime,[“h:mm A”]).format(“HH:mm”);
var startTimeS=时刻.duration(startTime,'ms').asSeconds();
var endTimeS=moment.duration(endTime,'ms').asSeconds();
$('.fc板条>表格>tbody>tr')。每个(函数(){
var time=moment(this.innerText.trim(),[“h:mma”]).format(“HH:mm”);
var timeS=时刻.持续时间(时间,'ms').asSeconds();
//卸下医生可以使用的颜色槽。
如果(timeS>=startTimeS&&timeS你能检查这个问题吗?这不是我想要的,我可以成功地设置事件和事件颜色,但我想根据我的情况对插槽的背景进行着色,我已使用我发布的上述解决方案解决了此问题。在看到您的解决方案之前,我已经实施了相同的解决方案。谢谢。