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

daypilot remove event using javascript event listener

Asked by Anonymous
3 years ago.

how to remove the event created when clicked on the "x"?

[1st pic]

this is my code on creating the event

[2nd pic]

i tried this one, but as expected, it doesn't work.

$(document).on('click', '.event_action_delete', function(e){
dp.events.remove(this);
});

please, help me with this. thank you!

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

The events.remove() method requires DayPilot.Event object. This is the recommended way to add a custom icon with an onclick event handler (using an active area):

<div id="dp"></div>
<script type="text/javascript">
  var dp = new DayPilot.Scheduler("dp");
  dp.onBeforeEventRender = function(args) {
    args.e.areas = [
      {
        top: 3,
        right: 2
        bottom: 9,
        width: 17,
        onClick: function(args) { dp.events.remove(args.source); },
        visibility: "Hover",
        css: "event_action_delete"
      }
    ];
  };
  // ...
  dp.init();
</script>

See also:
https://doc.daypilot.org/scheduler/event-deleting/

And:
https://doc.daypilot.org/scheduler/event-active-areas/

Comment posted by Anonymous
3 years ago.

it does not work :(

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