Problem/Motivation
The calendar is rendered with javascript and hence all html rendered in the calendar is not reachable by Drupal's behaviors.
Steps to reproduce
Try for example to click an ajax link rendered in the calendar events using the element class "use-ajax".
Proposed resolution
Add Drupal.attachBehaviors after the .render() function in fullcalendar_view.js.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | fullcalendar_view-3214419-8-trigger-drupal-behaviors.patch | 998 bytes | jessehs |
| #7 | fullcalendar_view-3214419-7-trigger-drupal-behaviors.patch | 3.63 KB | jessehs |
Issue fork fullcalendar_view-3214419
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
mingsongThanks Oscar for raising this issue.
I tried to add following lines after calendarObj.render();
While I drag and drop an even, I got an error said:
I am assuming that other modules remove the DOM created by Fullcalendar.js. It is why the 'null' is return.
I agree with that we need to work out a way to inform other modules about the changes made by Fullcalendar.js.
Comment #4
agogo commentedThanks for the response! I also tried that exact approach and noticed that this only makes the on screen rendered html affected. Switch view and were back to square one.
The reason I found the problem is that I need to be able to render content with ajax on onclick since the calendar view becomes unloadable with too many calendar events.
I'll post a way to make this work if/when I find it.
Comment #5
agogo commentedTroubleshooting this, the way I got it working was from running the datesRender callback and then running the attach on the rendered dates:
Drupal.attachBehaviors(info.el)I also went and removed the behaviors with the datesDestroy callback:
Drupal.detachBehaviors(info.el);For some reason I couldn't get the correct HTML within the eventRender callback and don't have time to troubleshoot further at the moment, but at least this is a step forward.
PS. I'm not receiving any errors with this implementation but that is probably due to the enviroment I'm working in and the events rendered.
Comment #6
kazah commentedSame problem.
If I try to log
calendarin custom behavior I gotundefined.But if I add settimeout for 1 second I get calendar object without problem.
Comment #7
jessehsThe technique mentioned in comment #5 appears to be working for me. It allows me to target and change bits of the calendar each time it is updated using a separate module's Drupal JS code. I've attached a patch that shows the changes. (Sorry for the extra noise, but my editor is configured to fix whitespace errors.)
Comment #8
jessehsOops. I left in console logging messages. This new patch also does not attempt to fix all the whitespace errors.
Comment #10
mingsongBeautiful!
Thanks Jesse and Oscar for your work on it.
Released with 5.1.7