Hello,
In the timeline view, I wish to display only those sections which have events in them. I have written the following code for filtering the sections (saw this code in previous answers on the forum) if it has events or not.
scheduler.attachEvent("OnViewChange", function (new_mode, new_date) { filterSection(); })
function filterSection(){
var display = scheduler.serverList("sections").slice();
for(var i = 0;i<display.length;i++){
if(!allowSection(display[i])){
display.splice(i,1)
i--;
}
}
scheduler.updateCollection("sections", display)
}
function allowSection(section){
var start = scheduler.getState().min_date;
var end = scheduler.getState().max_date;
var events = scheduler.getEvents(start,end)
if(section.label == events.label){
return true
}
return false
}
When I run this, the page takes a very long time to load and when I tried to debug it, I notice that in the attachEvent("OnViewChange")
function filterSection()
is being called constantly, even after the updateCollection()
method is called and the function ends properly.
Can you please look at it and see what mistake I am making here and how to fix this? If not this way, is there a simpler alternative way to do this?
** I get this error on the console of the browser**
Uncaught RangeError: Maximum call stack size exceeded