Problem/Motivation
When trying to load multiple calendars in one view, only the first instance loads. This is because the jQuery selector is targeting an ID, so it will stop once the first match is found when searching the page for calendars.
Proposed resolution
If we modify the jQuery selector used in the attach functions to include an additional selector that looks for a "unique" class, the selector will grab multiple calendar objects and initialize them:
$("#calendar", '.js-drupal-fullcalendar', context)
This fix will not cause any breaking changes to people already using the current ID selector, but will allow projects to utilize the class if they want to have multiple calendars in one view.
User interface changes
The template was updated to include the class on the base template. This will show an example while not impacting current behavior.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 306002-support-multiple-calendars-one-page.patch | 8.96 KB | providence_matt |
| #8 | fullcalendar_multi.4.patch | 8.96 KB | jberube |
| #7 | fullcalendar_multi.3.patch | 8.96 KB | jberube |
| #6 | fullcalendar_multi.2.patch | 9.42 KB | jberube |
| fullcalendar_multi.patch | 983 bytes | ammuench |
Comments
Comment #2
mingsongHi ammuench, thank you so much for raising this idea and contributing the patch.
I will test it out. Once it is bug free. I am happy to merge it into the Dev branch and get it ready for next release.
Comment #4
mingsongJust a minor issue that the jquery select string is incorrect. Jquery only accepts two parameters "jQuery( selector [, context ] )".
Comment #5
mingsongComment #6
jberube commentedI created a patch that does the following:
Comment #7
jberube commentedSorry, I didn't update my dev codebase to the latest for #6. This one is for the latest.
Comment #8
jberube commentedOk, I made another update. The class name was wrong.
Comment #9
jberube commentedComment #10
providence_matt commentedI was running into an issue where I needed two calendars on one page with different default layouts. One needed to be the month layout and the other needed to be the list layout. The patch in #8 would not apply. Using #8's logic I recreated the patch for the module version 8.x-2.4.
Comment #11
providence_matt commentedFixed patch in #10.
Comment #12
danflanagan8#11 works for 8.x-2.5 as well. It would be great to get this into the next release!
Update: #11 fails to apply to 8.x-2.6, which was released a couple weeks ago so it looks like there's more work before this can get into a release. I'll just stick with 2.5 for now!
Comment #14
mingsongThanks all for your patch, testing and feedback.
This feature has been added into the 9.x (8.x-4.3) branch based on the same idea as the patches above.
Comment #15
mandclu commentedJust so you're aware, the changes made here effectively changed the API for the FullcalendarViewProcessor, as it broke existing implementations, including the one in Smart Date. By convention it's typically considered best practice to move up a major version in your branch name (e.g. 5.x) when you change APIs like this.
Comment #16
karingI believe we can close this as outdated as this feature was added 2y ago. If I'm mistaken please let me know.
Good point @mandclu 👍