Solved

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

Posted on 2016-08-21
3
45 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 51

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 500 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now