I have a question. I'm using FullCalendar in a project. I can display the data registered in the bank normally.
My problem is in the eventClick: I did so:
var date = new Date();
var d = date.getDate(),
m = date.getMonth(),
y = date.getFullYear();
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
buttonText: {
today: 'today',
month: 'month',
week: 'week',
day: 'day'
},
eventClick: function (event, jsEvent, view) {
$.ajax({
type: "POST",
dataType: "json",
url: '<?php echo base_url(); ?>' + 'agenda/get_dados_evento/',
data: event.id,
async: true,
success: function (response) {
$("#evento").html(response.id_carro);
$("#modal").modal();
}
});
},
//Random default events
events: <?php print_r($eventos); ?>,
editable: true,
droppable: true, // this allows things to be dropped onto the calendar !!!
});
When I click on an event registered in the calendar, the event.id is sent to the controller
function get_dados_evento() {
$id_agenda = $this->input->post('id');
//$id_agenda = '24';
$query = $this->model_agenda->get_dados_evento($id_agenda);
echo json_encode($query->result());
}
Here is the model:
function get_dados_evento($id_agenda){
$this->db->select(""
. "agenda.id as id_agenda,"
. "agenda.id_carro as id_carro_agenda,"
. "agenda.title as titulo_agenda,"
. "agenda.start as dt_inicial,"
. "agenda.end as dt_final,"
. "agenda.dt_cadastro as data_cadastro_agenda,"
. "carro.id as id_carro,"
. "carro.modelo as modelo_carro,"
. "carro.placa as placa_carro,"
. "carro.fabricante as fabricante_carro,"
. "carro.tipo as tipo_carro,"
. "carro.ano_fabricacao as ano_fabricacao_carro,"
. "carro.kilometragem as kilometragem_inicial_carro,"
. "carro.status as status_carro,"
. "carro.dt_cadastro as data_cadastro_carro");
$this->db->where('agenda.id', $id_agenda);
$this->db->join('carro', 'agenda.id_carro = carro.id', 'inner');
$query = $this->db->get('agenda');
return $query;
}
My problem is when displaying the information in the view ... if I put the following code in block success:function(response){ console.debug(response); }
it prints the object. And at the time I try to display console.debug(response.id_carro);
it is undefined