NextEvent button next to Today button in the navline

I used this, from dhtmlxscheduler.css, as a template

and created a “.dhx_cal_nextEvent_button”. I added it next to the “Today” button.

I added the following in dhtmlxscheduler.js:

The Today button uses this code:

Does someone with better JS skills than mine have code for returning the date of the next future event?

If a user comes to the calendar and does not immediately see an event, I would rather they not have to hunt and peck to try to find the next event. It is in the scheduler._events list. And I could figure out the JS if I have to. But somebody here probably has the code on hand already, yes?

var from = new Date(); //current date, you can use scheduler.getState().date var events = scheduler.getEvents(from, new Date(9999,1,1)); events.sort(function(a,b){ return a.start_date < b.start_date ? 1 : -1; }); //events[0] is the nearest event //events[0].start_date - its start date

Hey! That worked. Coolio. Thanx.

Well, it seemed to work ok. But it caused issues. For example, there was a reproducible symptom that did this:

1 - go to the Months view, capture state of events. In my case, could see about 6.
2 - go back 2 months with the arrow link.
3 - click on the ‘Next Event’ tab.
4 - Observe, no problem.
5 - go back 2 months with the arrow link.
3 - click on the ‘Next Event’ tab.
4 - Observe, events are duplicated and moved around. Some times are set to 00:00.
5 - Click the re-load button.
6 - Observe, everything is back to normal.

This was reproducible multiple times. I want this button, but I will have to find the time to make it work properly.

Just FYI, the code provided to me is included at the top of docs.dhtmlx.com/doku.php?id=dhtmlxscheduler:tips. If there is a problem with it, there will be problems.

This code doesn’t alter events in any way, it just extract info and must not change anything in view.
If issue still occurs - can you provide any kind of sample or demo link where it can be checked ?