Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This is just to make it easier for people trying to achieve this feature. It has to do with the jQuery library and not the module itself. There is an issue filed for this in the library's queue. I don't take any credit for this code, merely duplicating it here for easier access I have only altered the line numbers to reflect actual ones...
Hi, I have adapted comment #12 to work with FullCalendar 1.5.2. Here's my contribution:
fullcalendar.js
line 3101:
slotBind(slotTable.find('td')); // new header bind headerBind(dayHeadCells);
line 3231:
function slotBind(cells) { cells.click(slotClick) .mousedown(slotSelectionMousedown); } function headerBind(days) { days.click(headerClick) .mousedown(daySelectionMousedown); } function headerClick(ev) { if (!opt('selectable')) { // SelectionManager will worry about dayClick var col = Math.min(colCnt-1, Math.floor((ev.pageX - dayTable.offset().left - axisWidth) / colWidth)); var date = colDate(col); var rowMatch = this.parentNode.className.match(/fc-slot(\d+)/); // TODO: maybe use data if (rowMatch) { var mins = parseInt(rowMatch[1]) * opt('slotMinutes'); var hours = Math.floor(mins/60); date.setHours(hours); date.setMinutes(mins%60 + minMinute); trigger('headerClick', dayHeadCells[col], date, false, ev); } else { trigger('headerClick', dayHeadCells[col], date, true, ev); } } }
And finally, in your fullCalendar init code you should define the headerClick callback:
headerClick: function (date, jsEvent, view) { // somehow the function 'view' argument has an empty value for "view.name" // so I get the view Object from the Calendar before use it. var view = $('.fullcalendar').fullCalendar('getView'); if (view.name == 'agendaWeek') { $(".fullcalendar").fullCalendar('gotoDate', date); $(".fullcalendar").fullCalendar('changeView', 'agendaDay'); }
That's all. Hope it helps
Comment | File | Size | Author |
---|---|---|---|
#2 | fullcalendar_1.5.2_whc.js_.txt | 127.28 KB | klonos |
#2 | fullcalendar_with_headerClick.diff | 1.25 KB | klonos |
#2 | fullcalendar-1.5.2-whc.zip | 144.08 KB | klonos |
Comments
Comment #1
tim.plunkettComment #2
klonos...here's a patched 1.5.2 version of fullcalendar.js that includes the headerClick extension (drupal.org renames the file to _.txt, so remove that). I'm also attaching a .diff and a full .zip
I don't know if there's something that needs to be done on the drupal module part though.
Comment #4
ryantollefson CreditAttribution: ryantollefson commentedI would love to see this option as well. I have tried to use the patched fullcalendar.js, but I think something needs to be changed in the drupal module for it to work.
Comment #5
klonosThere have been some updates to the bug filed over at http://code.google.com/p/fullcalendar/issues/detail?id=153 Once again: I don't claim any recognition - credits go to the original posters of the solutions at the issue linked previously...
Comment #6
klonos...while you go tying out these proposed solutions, please keep in mind that fullcalendar.js 1.7.2 seems to have known issues with the latest jQuery 1.8.0: http://code.google.com/p/fullcalendar/issues/detail?id=1499
Just a heads-up ;)
Comment #7
klonosUpdate from the issue again (as always, I claim no credits):
Comment #8
nerdoc CreditAttribution: nerdoc commentedHm @klonos - sorry to ask a 'newbie'-question. But is it enough to only add the code from #7 to my js file?
is this correct/enough?
It at least here does not work. Could you give me hint? The
attach
code is executed and works. But theviewDisplay
part is never executed. I use D7.31 and fullcalendar 1.6.