Our powerful JS Calendar component


Post by marland »

Hello everyone, is there a way to subscribe on delete button click for recurrence event?
For example i need to call my own function when user delete event. See image below:
https://drive.google.com/file/d/1TuBNhZ1gDk_V89LNip8qWZEyo6NW9jJZ/view?usp=sharing

For single event I subscribe like this:

listeners: {beforeeventdelete: onEventDelete}

But it doesn't work for recurrence events because of pop up window fires my event when on opening.
Could someone help me, please?


Post by saki »

To implement custom handlers of the buttons of the RecurrenceConfirmationPopup you need to override this class.

Add the following code in your app (or in our recurrence demo):

import Override from '../../lib/Core/mixin/Override.js';
import RecurrenceConfirmationPopup from '../../lib/Scheduler/view/recurrence/RecurrenceConfirmationPopup.js';
class RecurrenceConfirmationPopupOverride extends Override {
    static get target() {
        return {
            class   : RecurrenceConfirmationPopup,
            product : 'calendar'
        };
    }

    onChangeMultipleButtonClick() {
        console.log('onChangeMultipleButtonClick');
        this.processMultipleRecords();
        this.hide();
    }

    onChangeSingleButtonClick() {
        console.log('onChangeSingleButtonClick');
        this.processSingleRecord();
        this.hide();
    }

    onCancelButtonClick() {
        console.log('onCancelButtonClick');
        this.cancelFn && this.cancelFn.call(this.thisObj);
        this.hide();
    }
}

Override.apply(RecurrenceConfirmationPopupOverride);

The above sample contains copies of the original handlers with console.log added – you would replace these with your code.


Post by marland »

Is there a way to do it without overriding original events(I need their functionality). Maybe I can just listen for these 3 events, and call my function when are fired?


Post by saki »

Take a look at the source starting from line 60 please. Here we do not listen to events but we specify onClick function. That is the function you'll override above. The original functionality is easy to achieve, just by calling the original methods such as processSingleRecord(). The above sample does just that, only adding console logs.

Currently there is no easier/other way to do it.


Post by marland »

Thanks for the answer.


Post by marland »

Hello. How can i do this override if I integrate Bryntum Calendar using script tag like this : https://www.bryntum.com/docs/calendar/#Calendar/guides/gettingstarted/scripttag.md
I do not see Override.js and RecurrenceConfirmationPopup.js. I don't use Angular or other web frameworks.


Post by alex.l »

Hi marland,

I do not see Override.js and RecurrenceConfirmationPopup.js.

The guide you showed says:

From your scripts you can access our classes in the global bryntum namespace

So, no need to import, just use global bryntum namespace:

class RecurrenceConfirmationPopupOverride extends bryntum.calendar.Override {
    static get target() {
        return {
            class   : bryntum.calendar.RecurrenceConfirmationPopup,
            product : 'calendar'
        };
    }

All the best,
Alex


Post by alex.l »

Modern browsers support modules, no need to use frameworks to use modules, it's more comfortable and modern. So, if your use case allows you, I would suggest to use it instead https://www.bryntum.com/docs/calendar/#Calendar/guides/gettingstarted/es6bundle.md

All the best,
Alex


Post by marland »

Thanks, it's work!
Tell me please, how can I subscribe on delete button click single event (not recurrence)?
Now I am using like this:

listeners: {
   beforeeventdelete: onEventDelete
  },

But it fires for all events before they were deleted.


Post by alex.l »

Please check our docs: https://bryntum.com/docs/calendar/#Core/mixin/Events

Listeners can be configured to automatically deregister after first trigger by specifying config option once:

button.on({
  click: () => {},
  once: true
});

All the best,
Alex


Post Reply