Hi,
I want to delete an event in fullcalendar. I can delete the event, but only after refresh page the user sees that the event is deleted. so if the user press on delete the event is still vissible after the delete method.And also the event is deleted from the database
I have this:
var dataRow = {
'Id': EventID
}
$.ajax({
type: 'POST',
url: "/Calendar/DeleteEvent",
dataType: "json",
contentType: "application/json",
data: JSON.stringify(dataRow),
async: true,
processData:false,
cache:false,
success: function (data) {
alert(data);
$('#calendar').fullCalendar('refetchEvents');
},
error:function(xhr){
alert('error');
}
});
}
the strange thing is also that every time after delete is pressed,
error:function(xhr){
alert('error');
}
will be hitted.
Thank you
Oke
this is my button click of delete:
eventClick: function (calEvent, jsEvent, view) {
$('#btnPopupDelete').click(function () {
var id = calEvent.id;
DeleteEvent(id)
$('#popupEventForm').hide();
});
and this are my delete methods:
public static bool DeleteEvent(int Id)
{
try
{
LolaBikeContext db = new LolaBikeContext();
AppointmentDiary diary = db.AppointmentDiarys.Find(Id);
if (diary == null)
{
return HttpNotFoundResult();
}
db.AppointmentDiarys.Remove(diary);
db.SaveChanges();
}
catch (Exception)
{
throw;
}
return true;
}
and the delete controller action:
public bool DeleteEvent(int Id)
{
return DiaryEvent.DeleteEvent(Id);
}