Create Fullcalendar events filter

Asked

Viewed 451 times

2

1 answer

2

I had a question just like yours. I decided as follows: whenever the select is changed, you take the option value and use this value to filter from all the events you searched in ajax. An example would be:

$('#seleciona').change(function(){
$("#calendar").fullCalendar('removeEvents');//remove os eventos anteriores
var idEspacoFisico=$('#seleciona option:selected').val();//Pega o id do option
$.ajax({
    type:"POST",
    url:'eventos/getEventos.json', //Pega todos os eventos
    success: function(data){
        $.each(data,function(index,value){//Para cada valor do data, compara se o campo é igual ao filtro selecionado. Se for igual, renderiza.
            if(value.espacoFisico==idEspacoFisico){
                $("#calendar").fullCalendar('renderEvent', value, true);
            }
        })
    }
});
});
});

Browser other questions tagged

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