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

When someone clicks on active area, how do I stop the default event from firing?

Asked by Doug
7 months ago.

Question: in scheduler, for onBeforeEventRender, I add an active area with an onClick. How do I stop the onEventClick from the event from firing? If they click on the event area, there's no need to execute the event's onEventClick handler.

Thanks,
Doug

// Some of the code  (I can't figure out how to post code on here)

dp.onEventClick = function(args) {
  editBlock(args.e.id(), false);
};

dp.onBeforeEventRender = function(args) {
  args.data.areas = [
    {
      top: 7,
      right: 0,
      bottom: 9,
      width: 17,
      height: 17,
      onClick: function(args) {
        var areaObj;
        jQuery("#delete_block_dialog" ).dialog({
          // some dialog code here
        });
        return false;
      },
      visibility: "Visible",
      css: "fa fa-times delete_calendar_event"
    }
  ];
};
// etc.
Comment posted by Dan Letecky [DayPilot]
7 months ago.

You can prevent the click event to bubble to the event by specifying:

action: "None"

in the active area properties.

Please see also:
https://api.daypilot.org/daypilot-area-properties/

PS: You can highlight code snippets by wrapping it in < pre > code < /pre > (without spaces)

Answer posted by Doug
7 months ago.

That did not do what I was looking for, however, I looked at the docs at the link you sent and adding the following code to the area onClick works:

args.originalEvent.preventDefault();
args.originalEvent.stopPropagation();

I'm not sure if my terminology was correct in the question.

Comment posted by Dan Letecky [DayPilot]
7 months ago.

Great, thanks for posting the solution!

Comment posted by Dan Letecky [DayPilot]
7 months ago.

There was a bug in the action: "None" handling and it didn't work as expected. It's fixed now in the latest sandbox build (2019.4.4162).

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