search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Deleting event

Asked by Alex
6 years ago.

Hello All,

I'm using context menu to delete an event

{text:"Delete", onclick: function() { var e = this.source; dp.events.remove(e); } }

After deleting I supposed to handle onEventDelete and/or onEventDeleted to do some after actions.

But nothing happens. Event was deleted but no onEventDelete and/or onEventDeleted events.

Does it mean that I need to do some after actions after dp.events.remove(e)? For example, calling $.ajax method.

Thank you in advance.

Answer posted by Dan Letecky [DayPilot]
6 years ago.

Yes, there is no built-in onEventDelete event.

You can call dp.events.remove(e) and then notify the server:

  dp.events.remove(e);
  $.post("delete", { e: e.id() }, function() {
    dp.message("Deleted");
  }

Or you can call the server first and delete it on success:

  $.post("delete", { e: e.id() }, function() {
    dp.events.remove(e);
    dp.message("Deleted");
  }

Comment posted by Alex
6 years ago.

Thank you much.

Does it mean that onEventDelete and/or onEventDeleted events not implemented yet for JavaScript? Or could you explain when this events invoke and how to handle them?

Comment posted by Dan Letecky [DayPilot]
6 years ago.

There are onEventDelete and onEventDeleted events in the calendar:

http://api.daypilot.org/daypilot-calendar-oneventdelete/
http://api.daypilot.org/daypilot-calendar-oneventdeleted/

However, they are only fired when the user clicks the built-in delete icon in the CssOnly=false mode.

These events are not fired when you delete an event using dp.events.remove(). You don't need the event in this case because you have to invoke it manually so you can do the custom actions at the same time.

Similarly, no additional event is fired when you update events directly using dp.events.update().

Comment posted by Alex
6 years ago.

Thank you

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.