Events fired when calendar view first loaded?

  • 1
  • Question
  • Updated 2 years ago
Is there any kind of event fired when a calendar view is first loaded? I'd like to hook it.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
hmm, the only events that I could find are 'calendar.refreshed' and 'calendar.eventsDrawn', neither of which suits my purpose, unless I'm misunderstanding calendar.refreshed.

I have a settings object which includes a multipicklist field of the days of the week, which is designed to allow the user to select which days to show on all calendars by default.

Then I have this running on pageload on each page where I have a calendar component:
//Remove Non-default days from Week and Month Calendars
if( $('.nx-cal').length && $('.nx-cal-dowpicker').length) {
var defaults = skuid.$M('DefaultCenter') && skuid.$M('DefaultCenter').getFirstRow();
if (defaults) {
var daysString = defaults.Scheduling_Days__c,
daysArray = daysString.split(";"),
daysToClick = {};
//look into using $.map() for this?
$.each($t.dayNames,function(i,d){
if (daysArray.indexOf(d) === -1) {
$('.nx-cal-dowpicker').children()[i].click();
}
});
}
}

There are probably better ways to accomplish this than just clicking on the day with jQuery, but it works.

The problem is, this will only work for whichever calendar view is shown on pageload. If we switch views, the new view shows all days.

Any way I can cause skuid to run this code when a view is first loaded?