Link to home
Start Free TrialLog in
Avatar of bamapie
bamapie

asked on

FullCalendar JQ plugin: can't get defaultDate property to work

I'm just starting fooling around with the FullCalendar plugin.  But I can't get the most basic part of this to work the way I believe it should work: the defaultDate property.

I am using a moment.js instance to supply this date, and it does look to be a valid date.  But no matter what I do, the date I attempt to use is ignored and there are no special classes nor symbology applied to the date I attempt to use.

The calendar does display its "now" property.  Today's date is shaded lightly and has a "fc-state-highlight" class applied to it.  I would think that if my attempt to use defaultDate were working, I would see some change to that date as well.  

And if I am successfully setting defaultDate, why wouldn't that date carry a class with it so that I could symbolize it differently?  So I do believe that this is not working, for some reason.  

Here is my JS code:

      var $cal = $('#divRunsCalendar');

      if ($cal.length > 0) {

         var sDefaultDate = $cal.data('defaultdate');   // this contains '2016-08-11'
         var mDefaultDate = moment(sDefaultDate, 'YYYY-MM-DD');   // results in a valid moment.js date for 8/11/2016.

         $cal.fullCalendar({
            defaultDate: mDefaultDate,
            nowIndicator: true,
            defaultView: 'month',
            handleWindowResize: true,
            editable: true,
            selectable: true,
            selectHelper: true,
            unselectAuto: true,
            selectOverlap: true,
            eventOverlap: true,
            dragScroll: true,
            select: function (start, end, jsE, view) {
               var m1 = moment(start);
               var m2 = moment(end);
               m2 = m2.subtract('minutes', 1);
               var s1 = m1.format('YYYY-MM-DDTHH:mm');
               var s2 = m2.format('YYYY-MM-DDTHH:mm');
               alert('1: ' + s1 + '\r\r' + '2: ' + s2);
            },
            eventClick: function (e, jsE, view) {
               alert('eventClick');
            },
            eventMouseover: function (e, jsE, view) {
               alert('eventMouseover');
            },
            eventMouseout: function (e, jsE, view) {
               alert('eventMouseout');
            },
            eventResize: function (e, delta, revertFunc, jsE, ui, view) {
               alert('eventResize');
            },
            eventDrop: function (e, delta, revertFunc, jsE, ui, view) {
               alert('eventDrop');
            },
            dayClick: function () {
               alert('a day has been clicked!');
            }
         });
      }

Open in new window

Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Do you have a link we can look at?
Can you post what JS libraries you are using - the code on its own does not help us see your problem.
ASKER CERTIFIED SOLUTION
Avatar of Dustin Hopkins
Dustin Hopkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bamapie
bamapie

ASKER

Yep, it sure is using my date.  It just doesn't do anything at all to signify that my provided date is special.  Which is kind of surprising...I thought it would, at least, assign a class to that day that I could then choose to provide symbology for.

Thanks!