FULLCALENDAR - bring events

Asked

Viewed 634 times

1

We have in the Fullcalendar configuration the part of bringing the events in json form, I follow the following model:

$('#full-calendar').fullCalendar({
  events:{
          url: 'php_ajax/jq_agenda_calendario_dados.php',
          cache: true,      
          type: 'POST',
          data: {
                 param1: '',
                 param2: ''
                }
        }
});

Is there any way to pass parameters on url or in the data , because the way I’m doing I have to bring up the entire database with the events. I would like according to what the person goes advancing or backtracking in the calendar, to pass a parameter to bring only that period in which the person is viewing the calendar.

  • Currently you are passing 2 various parameters, are they: param1 and param2. You can also pass as get in the url itself: php_ajax/jq_agenda_calendario_dados.php?param1=valorQualquer&param2=outroValor.

  • I have tried to do this, but I can’t pass values for these variavia, I’m not able to bring any data to be put in them, see I created a pasterbin with the codigo https://pastebin.com/WC9sXhd On line 143 and entering the Events, but I’m not getting past the parameters.

  • I didn’t understand very well, in this part of the code url: 'php_ajax/jq_movi_pessoas.php?acao=e&foto='+foto, you are passing 2 parameters via get, ie in PHP script would spend capturing more or less like this: $_GET['acao'] and $_GET['foto']

  • This was a test I did, this excerpt is triggered by the button add events, which I put in fullcalendar. See there on line 143 that brings the event data, see, that the query I run brings all events, without any filter because I can’t pass any parameter to make a filter in the query. That’s what I’m trying to figure out. You happen to be able to filter the events for example according to the month/year being displayed by fullcalendar?

2 answers

2


document.addEventListener('DOMContentLoaded', function () {
                var calendarEl = document.getElementById('calendar');

                var calendar = new FullCalendar.Calendar(calendarEl, {
                    locale: 'pt-br',
                    plugins: ['dayGrid'],
                    defaultView: 'dayGridWeek',
                    events: {
                        url: 'url.php',
                        method: 'POST',
                        extraParams: {param1: 'param1', param2: $('#param2').val()},
                        failure: function () {
                            console.log('erro');

                        }
                    },
                    loading: function (bool) {
                        console.log('vai carregar'); 
                    }
                });

                calendar.render();
            });

1

Try this:

eventClick: function(event) {

                            $('#visualizar #id').text(event.id);
                            $('#visualizar #id').val(event.id);
                            $('#visualizar #title').text(event.title);
                            $('#visualizar #title').val(event.title);
                            $('#visualizar #start').text(event.start.format('DD/MM/YYYY HH:mm:ss'));
                            $('#visualizar #start').val(event.start.format('DD/MM/YYYY HH:mm:ss'));
                            $('#visualizar #end').text(event.end.format('DD/MM/YYYY HH:mm:ss'));
                            $('#visualizar #end').val(event.end.format('DD/MM/YYYY HH:mm:ss'));
                            $('#visualizar #color').val(event.color);
                            $('#visualizar').modal('show');
                            return false;

                        },

If you want to take a look at this fullcalendar: https://www.youtube.com/watch?v=SUlk2rMkKyc

  • I didn’t understand your answer regarding the question. Could edit your response and better detail the proposed solution.

  • Opa Andre Lira, I will check this and return thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.