Método do model que captura os dados do db:
function obter_noticias(){
$sql = "SELECT * FROM noticias WHERE noticias.data BETWEEN ? AND ? ORDER BY noticias.data";
return $this->db->query($sql, array($_GET['start'], $_GET['end']))->result_array();
}
Método do controller
que retorna o objeto json
function Test_Function(){
$noticias = $this->model->obter_noticias();
$obj = NULL;
//The cat's leap: criar o objeto para a variavel 'events'
foreach ($noticias as $i) {
$obj[] = [
'title' => $i['titulo'],
'start' => $i['data']
];
}
echo json_encode($obj);
exit();
}
javascript:
$(document).ready(function(){
$('#calendar').fullCalendar({
//alert('Teste de carregamento FullCalendar');
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay,listWeek,'
},
editable: false,
navLinks: true,
selectHelper: true,
events: {
url: 'dashboard/Test_Function',
type: 'POST',
data: {
value1: 'aaa',
value2: 'bbb'
},
success: function(data) {
console.log(data);
},
error: function() {
alert('Erro ao carregar eventos!');
},
}
});
});