所有
我目前正在使用Calendario.js,而且事情进展顺利。但是,我正在试图找出删除事件的方法。
我已经想出了如何通过传递给cal.setData()函数的字典添加事件。但是,当我从字典中删除一个事件并调用相同的cal.setData()函数时,它不会成功删除它。有人知道这样做吗?文档很稀疏。
HTML
<script type="text/javascript" src="{% static'main/Calendario/js/jquery.calendario.js' %}"></script>
<script type="text/javascript" src="{% static 'main/Calendario/js/modernizr.custom.63321.js' %}"></script>
<link rel='stylesheet' href="{% static 'main/Calendario/css/calendar.css' %}" />
<link rel='stylesheet' href="{% static 'main/Calendario/css/custom_2.css' %}" />
<link rel='stylesheet' href="{% static 'main/lightbox/lightbox.css' %}" />
<div class='container'>
<div class='col-md-8 col-md-offset-2'>
<div class="custom-calendar-wrap">
<div id="custom-inner" class="custom-inner">
<div class="custom-header clearfix">
<nav>
<span id="custom-prev" class="custom-prev"></span>
<span id="custom-next" class="custom-next"></span>
</nav>
<h2 id="custom-month" class="custom-month"></h2>
<h3 id="custom-year" class="custom-year"></h3>
</div>
<div id="calendar" class="fc-calendar-container"></div>
</div>
</div>
</div>
</div>
的Javascript
cal = $calendar.calendario( {
onDayClick : function( $el, $contentEl, dateProperties ) {
if(dateProperties.day.length==1){
dateProperties.day = 0 + dateProperties.day;
}
if(dateProperties.month.toString().length==1){
dateProperties.month = 0 + dateProperties.month.toString();
}
if($el.hasClass('fc-content')){
$el.removeClass('fc-content');
console.log($el);
delete codropsEvents[dateProperties.month + '-' + dateProperties.day + '-' + dateProperties.year];
}
else{
codropsEvents[dateProperties.month + '-' + dateProperties.day + '-' + dateProperties.year]='<a href="#"></a>'
console.log(codropsEvents);
cal.setData(codropsEvents);
}
if( $contentEl.length > 0 ) {
showEvents( $contentEl, dateProperties );
}
},
caldata : codropsEvents,
displayWeekAbbr : true
} ),
答案 0 :(得分:0)
如果您使用最新版本的Calendario - https://github.com/deviprsd21/Calendario,$('#calendar').calendario('setData', data, clearData);
,则非常容易,如果您在clearData中传递了true,则所有以前的数据都将被清除并替换为新数据。