Customize calendar with javascript

Hi all, I’m really hoping someone can help.

I’m creating an app with 2 calendars side by side in day view. I want to keep the calendars synchronised so that when clicking the ‘previous’, ‘next’ or ‘today’ buttons on one calendar executes the action on both calendars.

I’m sure this can be achieved in javascript, but I’ll be damned if I can make it work.

Can anybody help?

With thanks in advance, Neil.

Hello Neil,

Check out the page for the next and prev only
https://roberts.knack.com/farmers#calendar-test/

change id’s as per your view
var clicked = 0;
$(“#view_97 .fc-button-prev”).live(“click”, function () {
if (clicked == 0) {
clicked = 1;
$(“#view_39 .fc-button-prev”).trigger(“click”);

}
else
	clicked = 0

});

$(“#view_39 .fc-button-prev”).live(“click”, function () {
if (clicked == 0) {
clicked = 1;
$(“#view_97 .fc-button-prev”).trigger(“click”);

}
else
	clicked = 0

});

$(“#view_97 .fc-button-next”).live(“click”, function () {
if (clicked == 0) {
clicked = 1;
$(“#view_39 .fc-button-next”).trigger(“click”);

}
else
	clicked = 0

});

$(“#view_39 .fc-button-next”).live(“click”, function () {
if (clicked == 0) {
clicked = 1;
$(“#view_97 .fc-button-next”).trigger(“click”);

}
else
	clicked = 0

});

Regards,
Sunny Singla
info@sandt-consultancyservices.com

3 Likes

That’s just the job!

Thank you so much Sunny, you’re a hero :+1:

This is great! Actually, I’m wondering if someone can help me too. In Knack calendar view, let’s say someone is entering dates in December (but the “today” view is November), when someone enters dates in the future, it refreshes back to November. Is there a way that it refreshes to the current month/day last viewed? Please help!

Hello Michael,

Yes, that’s possible as well using javascript. we can save that value in some object and when load we can check the month and year and go to that date .

Regards,
Sunny Singla
+919855089359
info@sandt-consultancyservices.com