添加/删除事件源FullCalendar
我希望能够根据添加和删除eventSources来筛选事件。我找不到这样做的好例子添加/删除事件源FullCalendar,fullcalendar,Fullcalendar,我希望能够根据添加和删除eventSources来筛选事件。我找不到这样做的好例子 .fullCalendar( 'addEventSource', source ) .fullCalendar( 'removeEventSource', source ) 我希望有一些复选框来切换这些函数的执行。不过,我似乎无法让功能正常工作 $( "#target" ).click(function() { $('#calendar').fullCalendar( 'removeEventSource
.fullCalendar( 'addEventSource', source )
.fullCalendar( 'removeEventSource', source )
我希望有一些复选框来切换这些函数的执行。不过,我似乎无法让功能正常工作
$( "#target" ).click(function() {
$('#calendar').fullCalendar( 'removeEventSource', 'Event1' );
});
这是我的全部代码:
$('#calendar').fullCalendar({
header: {
left: 'title',
center: 'prev,next',
right: 'month,agendaWeek,agendaDay,today'
},
eventLimit: {
'agenda': 4, // adjust to 6 only for agendaWeek/agendaDay
'default': true // give the default value to other views
},
eventSources: [
{
title: 'Event1',
url: "http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic"
},
{
url: 'https://www.google.com/calendar/feeds/vineyardcincinnati.com_o6jncckm5ka55fpragnbp4mk9c%40group.calendar.google.com/public/basic'
},
{
url: "https://www.google.com/calendar/feeds/ht3jlfaac5lfd6263ulfh4tql8%40group.calendar.google.com/public/basic"
}
],
eventClick: function(event) {
// opens events in a popup window
window.open(event.url, 'gcalevent', 'width=700,height=600');
return false;
},
loading: function(bool) {
if (bool) {
$('#loading').show();
}else{
$('#loading').hide();
}
}
});
以下是我用来获取此功能的完整代码: HTML:
以下是我用来获取此功能的完整代码: HTML:
加载完整日历:使用以下给定代码加载完整日历。创建一个jquery函数,如LoadCalendar,并将下面的代码放入该函数中,然后在jquery中的document.ready函数上调用该函数
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
locale: '@companyCulture',
defaultDate: Date.now(),
defaultView: 'month',
navLinks: true, // can click day/week names to navigate views
editable: false,
eventLimit: true, // allow "more" link when too many events
dayClick: function (date, allDay, jsEvent, view) {
//$("#lblDate").html('' + moment(date).format("MMMM DD,YYYY hh:mm") + '');
$("#lblDate").html('' + moment(date).format("MMMM DD,YYYY hh:mm A") + '');
$("#hdRDate").val(moment(date).format());
emptyEventDetails(date);
// $("#AddEventModel").modal();
},
eventClick: function (calEvent, jsEvent, view) {
$.ajax({
type: "GET",
async: false,
cache: false,
url: "@Url.Action("GetEventById", "Events")",
data: {
Eventid: calEvent.id
},
success: function (data) {
emptyEventDetails();
//$.each(data.data, function () {
// alert(this["Title"]);
// var color = 'orange';
// var Title = this["Title"];
// //addCalanderEvent(this["EventID"], this["EventDate"], Title, color);
//});
}
});
//$("#lblDate").html('' + calEvent.EventDate + '');
//$("#hdRDate").val(calEvent.EventDate);
//$("#AddEventModel").modal();
}
});
添加事件:使用以下代码在FullCalendar中添加事件
var eventObject = {
title: title,
start: moment(start).format("MMMM DD,YYYY hh:mm A"),
end: moment(end).format("MMMM DD,YYYY hh:mm A"),
id: id,
color: colour
};
$('#calendar').fullCalendar('renderEvent', eventObject, true);
或
$('#calendar').fullCalendar( 'addEventSource', newSource); //Add a new source
$('#Calendar').fullCalendar( 'removeEvents').fullCalendar('removeEventSources'); //Removes all event sources
删除所有事件:我正在尝试删除fullcalendar插件中的所有事件源。我目前正在使用
$('#calendar').fullCalendar('removeEvents') //Hide all events
$('#calendar').fullCalendar('removeEventSource', $('.Source').val()) //remove eventSource from stored hidden input
或
$('#calendar').fullCalendar( 'addEventSource', newSource); //Add a new source
$('#Calendar').fullCalendar( 'removeEvents').fullCalendar('removeEventSources'); //Removes all event sources
加载完整日历:使用以下给定代码加载完整日历。创建一个jquery函数,如LoadCalendar,并将下面的代码放入该函数中,然后在jquery中的document.ready函数上调用该函数
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
locale: '@companyCulture',
defaultDate: Date.now(),
defaultView: 'month',
navLinks: true, // can click day/week names to navigate views
editable: false,
eventLimit: true, // allow "more" link when too many events
dayClick: function (date, allDay, jsEvent, view) {
//$("#lblDate").html('' + moment(date).format("MMMM DD,YYYY hh:mm") + '');
$("#lblDate").html('' + moment(date).format("MMMM DD,YYYY hh:mm A") + '');
$("#hdRDate").val(moment(date).format());
emptyEventDetails(date);
// $("#AddEventModel").modal();
},
eventClick: function (calEvent, jsEvent, view) {
$.ajax({
type: "GET",
async: false,
cache: false,
url: "@Url.Action("GetEventById", "Events")",
data: {
Eventid: calEvent.id
},
success: function (data) {
emptyEventDetails();
//$.each(data.data, function () {
// alert(this["Title"]);
// var color = 'orange';
// var Title = this["Title"];
// //addCalanderEvent(this["EventID"], this["EventDate"], Title, color);
//});
}
});
//$("#lblDate").html('' + calEvent.EventDate + '');
//$("#hdRDate").val(calEvent.EventDate);
//$("#AddEventModel").modal();
}
});
添加事件:使用以下代码在FullCalendar中添加事件
var eventObject = {
title: title,
start: moment(start).format("MMMM DD,YYYY hh:mm A"),
end: moment(end).format("MMMM DD,YYYY hh:mm A"),
id: id,
color: colour
};
$('#calendar').fullCalendar('renderEvent', eventObject, true);
或
$('#calendar').fullCalendar( 'addEventSource', newSource); //Add a new source
$('#Calendar').fullCalendar( 'removeEvents').fullCalendar('removeEventSources'); //Removes all event sources
删除所有事件:我正在尝试删除fullcalendar插件中的所有事件源。我目前正在使用
$('#calendar').fullCalendar('removeEvents') //Hide all events
$('#calendar').fullCalendar('removeEventSource', $('.Source').val()) //remove eventSource from stored hidden input
或
$('#calendar').fullCalendar( 'addEventSource', newSource); //Add a new source
$('#Calendar').fullCalendar( 'removeEvents').fullCalendar('removeEventSources'); //Removes all event sources
“source参数非常灵活。您可以提供事件源的数组/URL/函数,也可以指定完整的事件源对象。”标题不是其中之一。由于某种原因,这似乎也不起作用$(“#calendar”).fullCalendar('removeEventSource',eventSources[0]);URL对我有用:$(“#目标”).click(函数(){alert(.click()调用的处理程序”);$(“#日历”).fullCalendar('removeEventSource',”);});“source参数非常灵活。您可以提供事件源的数组/URL/函数,也可以指定完整的事件源对象。”标题不是其中之一。由于某种原因,这似乎也不起作用$(“#calendar”).fullCalendar('removeEventSource',eventSources[0]);URL对我有用:$(“#目标”).click(函数(){alert(.click()调用的处理程序”);$(“#日历”).fullCalendar('removeEventSource',”);});