?
Solved

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

Posted on 2016-08-21
3
Medium Priority
?
160 Views
Last Modified: 2016-08-22
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

0
Comment
Question by:bamapie
3 Comments
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 41764829
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.
0
 
LVL 14

Accepted Solution

by:
Dustin Hopkins earned 2000 total points
ID: 41764846
Today is highlighted because it's today not because it's the default date. IIRC full calendar doesn't do anything to the default date except put the calendar on the proper month.

To test if it's being set try passing a date from previous month or year and see that it defaults to the proper page.  

Hope this helps,
Dustin
0
 

Author Closing Comment

by:bamapie
ID: 41766112
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!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question