How to Change the visible week on the Calendar Component using Javascript?

  • 2
  • Question
  • Updated 2 years ago
Is there a way to change the visible week on the Calendar Component using Javascript?

Basically, I have a Page Title with "Previous" and "Next", and I'd like to use these buttons much like the default week-to-week navigation - but with the added potential of using the Action Framework too.


Is there a js function that I can use to change what week the Calendar Component displays?
Photo of mB Roman Melnik

mB Roman Melnik

  • 2,802 Points 2k badge 2x thumb

Posted 3 years ago

  • 2
Photo of Gary

Gary

  • 1,518 Points 1k badge 2x thumb
Hi Roman, suspect this is too late for you, but for posterity's sake...

The datepicker in the calendar uses jQuery UI's datepicker - so you should be able to do something like:


var datepicker = $(".hasDatepicker"); 
datepicker.datepicker("option", "setDate", new Date(2016, 5, 3));
Or something to that effect. You could also do it the other way around - attach a listener to changes to the date in the datepicker and then run your own Javascript (which could in turn call your snippets).
(Edited)
Photo of mB Roman Melnik

mB Roman Melnik

  • 2,802 Points 2k badge 2x thumb
Hi Gary, yes this is in fact the approach that we ended up using - and it works quite well.

Thanks for responding to my original question so that others can see the solution. (I had forgotten that i even posted this haha!)