在fullcalendar中删除事件 [英] Delete event in fullcalendar
问题描述
我想在fullcalendar中删除一个事件。我可以删除该事件,但只有在刷新页面后,用户才会看到该事件被删除。因此,如果用户按下删除,删除方法后事件仍然是可变的。此事件也将从数据库中删除
我有这个:
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');
}
});
}
奇怪的是每次按下删除后,< br $>
the strange thing is also that every time after delete is pressed,
error:function(xhr){
alert('error');
}
将被点击。
谢谢
Oke
这是我点击删除的按钮:
< br $>
will be hitted.
Thank you
Oke
this is my button click of delete:
eventClick: function (calEvent, jsEvent, view) {
//alert(calEvent.start);
$('#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);
}
推荐答案
.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(数据);
.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');
},
错误:函数(xhr){
alert(' 错误跨度>);
}
});
}
('#calendar').fullCalendar('refetchEvents'); }, error:function(xhr){ alert('error'); } }); }
奇怪的是每次按下删除后,< br $>
the strange thing is also that every time after delete is pressed,
error:function(xhr){
alert('error');
}
将被点击。
谢谢
Oke
这是我点击删除的按钮:
< br $>
will be hitted.
Thank you
Oke
this is my button click of delete:
eventClick: function (calEvent, jsEvent, view) {
//alert(calEvent.start);
(' #btnPopupDelete')。click(function(){
var id = calEvent.id;
DeleteEvent(id)
('#btnPopupDelete').click(function () { var id = calEvent.id; DeleteEvent(id)
这篇关于在fullcalendar中删除事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!