CLNDR icon indicating copy to clipboard operation
CLNDR copied to clipboard

Multiple calendars on a page

Open jeremiecarlson opened this issue 13 years ago • 3 comments

I'm trying to wrap my head around it, but I can't seem to think of a way to get multiple calendars with different events on a single page to work. Any pointers?

jeremiecarlson avatar Nov 26 '13 19:11 jeremiecarlson

You might want to check #40 out. You basically want to create n clndr instances. I'm actually working on something like that and the only problem we have run into is switching all (3 in our case) months. That was solved by a custom handler and calling previos/next on all of the calendars in a collection.

DawidJanczak avatar Nov 27 '13 03:11 DawidJanczak

@jeremiecarlson each calendar instance can take a different array of events, for example:

var firstEventsArray = [{ date: '2013-11-27' }, ... ];
var secondEventsArray = [{ date: '2013-12-25' }, ... ];

$('#calendar1').clndr({
  events: firstEventsArray
});

$('#calendar2').clndr({
  events: secondEventsArray
});

As @DawidJanczak pointed out, you can write an event handler that is shared between all of the calendar instances if you need to link several to the same next/previous action.

Does that answer your question?

kylestetz avatar Nov 27 '13 13:11 kylestetz

@DawidJanczak Thanks, I really should have checked closed issues - my bad.

@kylestetz Yeah, sorry I was being kinda vague in my question. I have 2 main issues:

  1. Getting the events from a back-end service and associating them with the correct instance of clndr, but I think I should be able to do that by getting back-end to spit it out on the page, and I'll look through available events arrays... We'll see.
  2. Event handling (binding prev/next only to that instance) which looks like I can work with #40

Thank you for your quick responses

jeremiecarlson avatar Nov 27 '13 17:11 jeremiecarlson