Create FullCalendar Event Filter

2

Good morning, I would like to know how do I create a filter in a dropdown that will return me certain events. An example is this: link , but with a dropdown. I glanced at some materials, but nothing that could help me. Thanks

    
asked by anonymous 09.11.2016 / 16:05

1 answer

2

I had a question just like yours. I solved it as follows: whenever the select changes, you get the value of the option and use this value to filter out all the events you've searched for 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);
            }
        })
    }
});
});
});
    
05.01.2017 / 16:34