Solved

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

Posted on 2016-08-21
3
62 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 54

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Converting dates in JavaScript 2 32
jquery datatables, asp.net MVC 9 39
simple javascript form validation 2 18
Scroll 5 news at a time. 4 25
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 …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
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…

785 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