add some kind of custom check for button next and prev

I found this code on your forum, I want to use it.
the problem is that the “scheduler._click.dhx_cal_next_button” does not work with me
i want to add some kind of custom check in botton next and prev by using the function below but it’s not working.
the green part work but the red part don’t work.
I thank you in advance.

schedulre.original_next = scheduler._click.dhx_cal_next_button;
scheduler._click.dhx_cal_next_button = function(){
    if (some_custom_check())

scheduler.original_prev = scheduler._click.dhx_cal_prev_button;
scheduler._click.dhx_cal_prev_button = function(){
    if (some_custom_check())

it’s better to handle this by using an API events rather than a private properties.
Try catching onBeforeViewChange and check state of scheduler in the handler,
here is an example: … event.html