Subho
Subho

Reputation: 923

how to solve $.fullCalendar.formatDate is not a function

I am using full calendar api for my application ,I am trying to disable the past dates in the fullcalendar ,but I am getting $.fullCalendar.formatDate is not a function error.I am posting my code

select : function(start, end, allDay) {
        $('#clickedDateHolder').val(start.format());
        // show modal dialog
        var check = $.fullCalendar.formatDate(start,'yyyy-MM-dd');
        var today = $.fullCalendar.formatDate(new Date(),'yyyy-MM-dd');

        if(check < today)
        {
            bootbox.alert("Past Dates")
        }else{
            input.push(date.format());
            $('#selectedDate').val(input);
            $('#event-modal').modal('show');

So in this code I am trying to see which date is past date in fullcalendar and trying to give a message of that but each time I am getting this error.Somebody please help

Upvotes: 1

Views: 8658

Answers (2)

Avatar
Avatar

Reputation: 15156

FullCalendar's formatDate() was only for versions below 2.0. See here: http://fullcalendar.io/wiki/Upgrading-to-v2/

$.fullCalendar.formatDate → use a moment's .format() method instead

So instead of

$.fullCalendar.formatDate(start,'yyyy-MM-dd');

you have to use

moment(start, 'DD.MM.YYYY').format('YYYY-MM-DD')

whereas 'DD.MM.YYYY' is the recent format of start and format('YYYY-MM-DD') specifies the target format. Pay attention, you need to use capitalized letters.

Upvotes: 9

Domain
Domain

Reputation: 11808

your scripts might be conflicting with some other scripts, try adding all your code inside this instead of $(document).ready()

jQuery.noConflict();
(function( $ ) {
  $(function() {
    // your code
  });
})(jQuery);

Upvotes: 0

Related Questions