[英]fullcalendar, deleting event on button click
i am trying delete events when i click in button "x", but not work, and not getting any error.当我单击按钮“x”时,我正在尝试删除事件,但不起作用,也没有收到任何错误。
I assign the function click in parameter "eventRender".我在参数“eventRender”中分配了单击功能。
This is my code with JavaScript:这是我的 JavaScript 代码:
$('#calendar').fullCalendar({
locale: 'es',
weekends: false, //ocultar fines de semana
defaultView: 'agendaWeek',
allDaySlot: false,
header: {
left: 'month,agendaWeek,agendaDay,listDay',
center: 'title',
right: 'prev,next today'
},
height: 'auto',
minTime: "10:00:00",
maxTime: "20:00:00",
editable: true,
//droppable: true, // this allows things to be dropped onto the calendar
dayClick: function(date, jsEvent, view) {
console.log('Clicked on: ' + date.format());
console.log('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
console.log('Current view: ' + view.name);
var hoy = moment();
if(date.format("YYYY-MM-DD HH:mm") >= hoy.format("YYYY-MM-DD HH:mm")){
asignarCita(date);
}else{
swal({
title: "Cita no disponible",
text: "La fecha u hora seleccionada ya ha pasado."
});
}
},
eventRender: function(event, element) {
element.prepend( "<div class='ibox-tools'><a style='background-color: transparent; margin-right: 10px' class='pull-left'><i class='fa fa-times closeon'></i></a></div>" );
//element.append( "<span class='closeon'>X</span>" );
console.log(element.find('closeon'));
element.find(".closeon").click(function() {
$('#calendar').fullCalendar('removeEvents',event._id);
});
},
events: [
{
title: 'All Day Event',
start: '2014-10-01'
},
{
title: 'Long Event',
start: '2014-10-07',
end: '2014-10-10'
},
{
id: 999,
title: 'Repeating Event',
start: '2014-10-09T16:00:00'
},
],
});
Where is the problem?问题出在哪里?
Try this:试试这个:
eventRender: function(event, element, view) {
if (view.name == 'listDay') {
element.find(".fc-list-item-time").append("<span class='closeon'>X</span>");
} else {
element.find(".fc-content").prepend("<span class='closeon'>X</span>");
}
element.find(".closeon").on('click', function() {
$('#calendar').fullCalendar('removeEvents',event._id);
console.log('delete');
});
},
https://jsfiddle.net/vc9ytv2k/ https://jsfiddle.net/vc9ytv2k/
The current version of FullCalendar has different API当前版本的 FullCalendar 有不同的 API
eventRender: function(info) {
$(info.el).append("<span class='removebtn'>X</span>");
$(info.el).find(".removebtn").click(function() {
info.event.remove();
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.