admin管理员组文章数量:1410712
I have one click event and inside of it I am reloading the fullcalendar. But after the reloading I would like to hide current element on which the click event is performed. But somehow its not working. Below is my code.
$(document).on("click", 'a.btnExpandCollapseBook', function (e) {
$('#calendar2').fullCalendar('destroy');
calendarOptions.events = tempSourcearr; // assigning the events
$('#calendar2').fullCalendar(calendarOptions);
$(this).hide();// This is not working...
});
I have one click event and inside of it I am reloading the fullcalendar. But after the reloading I would like to hide current element on which the click event is performed. But somehow its not working. Below is my code.
$(document).on("click", 'a.btnExpandCollapseBook', function (e) {
$('#calendar2').fullCalendar('destroy');
calendarOptions.events = tempSourcearr; // assigning the events
$('#calendar2').fullCalendar(calendarOptions);
$(this).hide();// This is not working...
});
Share
Improve this question
asked Dec 5, 2015 at 6:08
Rakesh AngreRakesh Angre
2551 gold badge4 silver badges12 bronze badges
2
- You need to search through the array of events and remove the current event before assigning the events again.. Also, how do you get the currently clicked event? – VisualBean Commented Dec 7, 2015 at 10:32
- Out of curiousity, why are you wanting to destroy and re-initialize the calendar upon event click? – smcd Commented Dec 7, 2015 at 16:17
3 Answers
Reset to default 1You can add a custom property, example 'hidden' true/false, to the event and use eventRender to control the visibility based off the 'hidden' property
http://jsfiddle/hmspswu3/
var calendarOptions = {
defaultDate: '2015-12-01',
events: [{
id: 1,
start: '2015-12-03',
end: '2015-12-07',
title: 'Event 1',
hidden: false
}, {
id: 2,
start: '2015-12-13',
end: '2015-12-17',
title: 'Event 2',
hidden: false
}],
eventRender: function(event, element, view) {
return !event.hidden;
},
eventClick: function(event, jsEvent, view) {
event.hidden = true;
calendarOptions.events = $('#calendar').fullCalendar('clientEvents');
$('#calendar').fullCalendar('destroy');
$('#calendar').fullCalendar(calendarOptions);
}
};
$('#calendar').fullCalendar(calendarOptions);
Thanks for Every one, I found the alternative solution for this as below.
$.each($('#calendar2').fullCalendar('clientEvents'), function (i, item) {
$('#calendar2').fullCalendar('removeEvents', item.id);
}); // removes the event one by one
$('#calendar2').fullCalendar('addEventSource', tempSourcearr); // assign the new data source.
For destroying use :
$('#calendar2').fullCalendar('destroy');
本文标签: javascriptFull Calendar Destroy eventStack Overflow
版权声明:本文标题:javascript - Full Calendar Destroy event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744865128a2629300.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论