Sections in UnitsView aren't rendered when date is cached

I have a scheduler with a units view. All events and sections to the units view are loaded from the server side. The initialization code looks like this:

(function() { 
    var photographers = scheduler.serverList('photographers');
    scheduler.init('calendar', null, 'day');
      name: 'photographers',
      property: 'photographer_id',
      list: photographers
    scheduler.load(location.pathname + '/data');

Everything is working correctly for uncached dates loaded from the db, the problem is when I try to go to a date that has already been loaded, and hence is cached by scheduler. The events are shown correctly, but the sections in the units view are not. They’re stuck at the last sections loaded from the db.
I tried using

scheduler.config.prevent_cache = true;

But that didn’t help, so I had to go with this ugly little bastard:

scheduler.attachEvent('onViewChange', function() { setTimeout(function() { scheduler._loaded = {}; }, 1000); return true; });

Which basically clears schedulers cache after each view change.

The reason for the timeout is to avoid scheduler entering an infinite loop, although I think I can go quite much lower on the timer.

The big downside of having to do this is of course that i’m disabling scheduler’s cache, which introduces extra time and performance penalty when loading dates which have already been shown.

To me this looks like a bug, but maybe someone else familiar with the code can shed some more light on this?


This is not expected usage scenario.

Code of scheduler expects that list of units is a constant value, and specified only once.
The situation when list of units is reloaded each time when new data loaded is just a side-effect functionality, which was not expected.

Cache, on other hand, doesn’t store information about units list for specific date. So when data taken from cache there is no way to restore related list of units.

I see only two solution, none of which is very good:

a) use constant list of units
b) do not use cache ( there is no native code for that, logic which you are using now has not side effects, and I think you can set timeout as small as 1ms - real timing doesn’t matter )

For your use-case, will it be enough to have constant list of units, but units which has not events will be automatically hidden ?

( there is no such functionality as well, but we are refactoring this extension now, and may add some useful extras )

Yes, having a constant list of units where units without events are hidden would work fine for my scenario.

I do think the possibility of relating units to given dates should also be taken into consideration. The only reason this works in my scenario is because I have a fairly small list of possible units. (15-20), but if the list was a tenfold, this would start getting slow.

Of course I have no idea how much work this involves, but the only change I see necessary is that the scheduler caches units in relation to dates.

Thank you anyway for your replies, they tell me I can keep this as they are for now.