Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2016-08-21
3
Medium Priority
?
134 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 59

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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

636 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