itepifanio
itepifanio

Reputation: 568

There's a way to refetch fullcalendar in v3?

I don't want to refetch fullcalendar events. I have a ajax which refresh the var date and I want to refresh the fullcalendar to set new maxDate and minDate to the calendar. The way I'm doing the values changes, but the maxDate and minDate of the calendar doesn't work

let date = {
    'maxDate': moment().toDate(),
    'minDate': moment().subtract(365, "days").toDate()
};

$('#calendar').fullcalendar({
    // [...]
        minDate: date['minDate'],
        maxDate: date['maxDate'],
    // [...]
});

// [...]

$("#input_calendar").on('change', function () {
    $.ajax({
        url: "{{ route('calendarioOferta.datas') }}",
        method: "GET",
        data: {
            'calendar': $(this).val()
        },
        success: function (data) {
            date = data;
        }
    });
});

Upvotes: 0

Views: 64

Answers (1)

thatgibbyguy
thatgibbyguy

Reputation: 4103

It looks to me like you will need to just set the calendar on your success call. Right now you are just changing the var date to be set to your data on success, but nothing is saying to reset the full calendar.

var setFullCalendar = function(dateData) { 
  $('#calendar').fullcalendar({
    // [...]
        minDate: dateData['minDate'],
        maxDate: dateData['maxDate'],
    // [...]
  });
}

$("#input_calendar").on('change', function () {
    $.ajax({
        url: "{{ route('calendarioOferta.datas') }}",
        method: "GET",
        data: {
            'calendar': $(this).val()
        },
        success: function (data) {
            setFullCalendar(data);
        }
    });
});

Upvotes: 1

Related Questions