单击事件编辑器上的取消按钮时触发'onEventDeleted'('onEventDeleted' trigger when click on cancel b

编程入门 行业动态 更新时间:2024-10-10 05:23:35
单击事件编辑器上的取消按钮时触发'onEventDeleted'('onEventDeleted' trigger when click on cancel button on the event editor)

我正在使用DHTMLX调度程序 ,我试图在弹出事件编辑器中点击删除按钮时删除一个事件,下面是我的代码参考。

scheduler.attachEvent("onEventDeleted", function(id,ev){ $.ajax({ url : "calendar.php", type: 'post', data: { event_id : id}, success: function(e){ if($.trim(e) === "success"){ alert("Event was successfully deleted"); } } }); });

上面的代码工作(事件被成功删除),但问题是,当我从弹出编辑器中单击取消按钮时,'onEventDeleted'也会触发。 任何想法,帮助,建议,建议,请帮忙吗?

Im using DHTMLX scheduler and I'm trying to delete an event when click on the delete button in the popup event editor, below is my code reference.

scheduler.attachEvent("onEventDeleted", function(id,ev){ $.ajax({ url : "calendar.php", type: 'post', data: { event_id : id}, success: function(e){ if($.trim(e) === "success"){ alert("Event was successfully deleted"); } } }); });

the above code works (The event was deleted successfully) but the problem is, the 'onEventDeleted' did also trigger when i click the cancel button from the popup editor. Any ideas, help, suggestions, recommendations, help please?

最满意答案

只有在创建新事件时按取消才会发生这种情况。 在这种情况下,预期会触发onEventDeleted,因为它会从日历中删除新创建的事件。 为了不将该更新发送到后端,您可以使用此方法http://docs.dhtmlx.com/scheduler/api__scheduler_getstate.html

因此,如果你更新代码如下,一切都应该是好的:

scheduler.attachEvent("onEventDeleted", function(id,ev){ if(scheduler.getState().new_event) return; $.ajax({ url : "calendar.php", type: 'post', data: { event_id : id}, success: function(e){ if($.trim(e) === "success"){ alert("Event was successfully deleted"); } } }); });

It happens only if you press cancel while creating a new event. In this case triggering onEventDeleted is expected since it removes a newly created event from a calendar. In order not to send that update to the backend you can use this method http://docs.dhtmlx.com/scheduler/api__scheduler_getstate.html

So if you update code like following everything should be good:

scheduler.attachEvent("onEventDeleted", function(id,ev){ if(scheduler.getState().new_event) return; $.ajax({ url : "calendar.php", type: 'post', data: { event_id : id}, success: function(e){ if($.trim(e) === "success"){ alert("Event was successfully deleted"); } } }); });

更多推荐

本文发布于:2023-07-06 07:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1047478.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单击   按钮   器上   编辑   事件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!