updateView removes current time marker

updateView’s doc says that it only refreshes and does nothing else. Each time I call it the now marker disappears.
I added a snippet where I reproduced the issue. I call updateView after 2 seconds so it is more obvious that the red line disappears.

DHTMLX Snippet Tool

I need this to work in my app as I want to call a function that fetches events from my server “onViewChange” and I want to do this. I can also not use setCurrentView as this would result in a refresh loop as it triggers onViewChange…

this.scheduler?.clearAll();
this.scheduler?.parse([
  ...calendarInfos.wpCalendarEvents,
  ...calendarInfos.absencesCalendarEvents,
  ...calendarInfos.attendancesCalendarEvents,
]);
this.scheduler?.updateView();

Does anybody know why this happens or how I can avoid that?

Hello @leherv,

updateView’s doc says that it only refreshes and does nothing else. Each time I call it the now marker disappears.

Yes, that’s correct behavior, as view refresh removes all additional elements(that is mark_now marker)

I need this to work in my app as I want to call a function that fetches events from my server “onViewChange” and I want to do this.

Regarding the provided code:

this.scheduler?.clearAll();
this.scheduler?.parse([
  ...calendarInfos.wpCalendarEvents,
  ...calendarInfos.absencesCalendarEvents,
  ...calendarInfos.attendancesCalendarEvents,
]);
this.scheduler?.updateView();

If you are calling clearAll and parse method - it’s not necessary to call additional updateView, as all parsed events will be automatically rendered, so you can remove it from the code:

this.scheduler?.clearAll();
this.scheduler?.parse([
  ...calendarInfos.wpCalendarEvents,
  ...calendarInfos.absencesCalendarEvents,
  ...calendarInfos.attendancesCalendarEvents,
]);

Demo:
https://snippet.dhtmlx.com/wwrlo2zo

Or if you still want to keep additional render, you can use setCurrentView and add some flag variable, that will allow calling setCurrentView for only first viewChange call, and reset this variable on some timeout.

Kind regards

Hello @Siarhei!

Thanks for the reply and help. The doc for updateView should also state the difference in side-effects. This cost me a lot of time and nerves for nothing.
Also yes I sadly need setCurrentView with a boolean flag now (which is also very ugly) as I also color certain days differently depending on the data received from the backend. Otherwise parse would suffice…

Thanks again for the help though,

Kind regards