2

My current calendar looks like this :

full-calendar design

What I'm trying to do is change calendar date when I click a date in datepicker ( which is already done using .fullCalendar('gotoDate',date ) ) , the thing is , to get the resources and events I need to re-send the query to the server with the new value of 'date' , otherwise the calendar won't reload the data.

Here's the url I'm using to get the resources :

resources: 
            {

                url: '/general?handler=AllResources', 
                data: function () { 
                    return {
                        // must return the new date to display in calendar
                    };

                }
            }

'AllResources' method only get a few records depending on the date specificied as parameter.

BTW : I'm rendering fullCalendar in document.ready , then I have the following function to give my datepicker the 'changeDate' functionality :

$('.fc-center h2').datepicker({
                format: "dd/mm/yyyy",
                language: "es",
                dateFormat: "dd/mm/yyyy",
                todayHighlight: true

            }).on("changeDate", function (e) {


                var date = moment(e.date);

                $("#calendar").fullCalendar('gotoDate', date);




            });

1 Answers1

0

Im not sure if i unserstand your problem.

So if you change the date, the resources don't get updated? Have a look at refetchResourcesOnNavigate

[edit] Try this:

$('.fc-center h2').datepicker({
                format: "dd/mm/yyyy",
                language: "es",
                dateFormat: "dd/mm/yyyy",
                todayHighlight: true

            }).change(function (e) {
             var mydate =moment($(this).val(),'DD/MM/YYYY').format('YYYY-MM-DD');

       $("#calendar").fullCalendar('gotoDate', mydate);

});

And then when initializing the calender set 'refetchResourcesOnNavigate: true' to make sure whenever the calendar changes the resources get loaded again

John
  • 536
  • 6
  • 18
  • Yes, when the fullCalendar is already rendered I haven't selected a datepicker's date yet , so obviously it doesn't know what parameter ( date ) send in the URL . – Christian Bejarano Dec 13 '18 at 15:24
  • so if you select a date in the datepicker, your calendar updates to the correct date but the resources don't change? – John Dec 13 '18 at 15:30
  • i edited my reply. there was also a problem with the date format – John Dec 13 '18 at 16:46
  • 1
    adding refetchResourcesOnNavigate:true did the thing , thanks man . However , the other views doesn't show the events ( month , week , 2 day views ) , I wrote a new question about it , I'd appreciate if you could check it out : https://stackoverflow.com/questions/53766583/show-events-in-all-the-views-of-fullcalendar – Christian Bejarano Dec 13 '18 at 16:57
  • The link to your other question won't load. Let me know if you still need help with that – John Dec 14 '18 at 02:12
  • Unfortunately your other question is on hold. I think it can answer it. Please edit the question – John Dec 14 '18 at 10:55