3
I would like to know how to get other components (besides id, title, start and end) in Fullcalenda.
I have a table, in the database, which has several fields such as status, responsibility, department, etc... And I make a query in this table that returns a PHP JSON for Fullcalendar. There in Fullcalendar I can only get the default Fullcalendar attributes that are id, title, start and end.
How do I get the other attributes resulting from the database query (fields such as status, responsibility, etc ...) ?
The result of my query is the array below:
- In the image above, I can get the title, start, end and color (which are native to Fullcalendar), but I can’t get the type and STATUS. How to do this ?
Below follows the code in which I receive the data in Fullcalendar:
events: {
url: '../banco/banco-get/pagina-dashboard/classes-dashboard-calendario.php', //Página PHP que realiza a consulta
failure: function() {
document.getElementById('script-warning').style.display = 'block'
}
},
eventClick: function(info) {
//O parâmetro 'info' é que contém os valores que vem do retorno da consulta do banco de dados
info.jsEvent.preventDefault();
//Passando valores para os elementos HTML
$('#visualizar #mostrar-titulo').text(info.event.title);
$('#visualizar #mostrar-inicio').text(info.event.start.toLocaleString());
$('#visualizar #mostrar-fim').text(info.event.start.toLocaleString());
$('#visualizar #mostrar-status').text(info.event.STATUS);
//Exibe o modal (quando clicamos no respectivo evento) que mostra as informações resultantes da consulta no banco de dados.
$('#visualizar').modal('show');
},
Now look how the modal is displayed (when we click on the respective event) with the information:
- Note that the STATUS does not appear.
It makes no sense to use the selectors as
"#visualizar #mostrar-titulo"
... an id should be unique on the page, so it makes no sense to fetch the id#mostrar-titulo
within another id#visualizar
.– Sam
Yes, Sam. But that’s because I didn’t post the HTML. This "#view" is the id of a modal, and the "#show title" is the id of the fields that will be filled with the data coming from the query. They are filled in within the Fullcalendar. But these fields are static and this modal is only opened when we click on the event (and the data is passed to the modal fields only at this moment). Not many "#view" modals are created. Only one. I didn’t put the HTML code because I didn’t think it would have relevance to the problem itself.
– Gato de Schrödinger
I know. What I meant was to use
$('#visualizar #mostrar-titulo').text(info.title);
it makes no sense, when you should use$('#mostrar-titulo').text(info.title);
since an id is unique.– Sam
Come on, Sam. kkkkkkk. You’re being a fucking perfectionist. The problem was just adding the "#visualize" to the dial ?
– Gato de Schrödinger