jquery fullcalendar event filtering

后端 未结 4 2031
盖世英雄少女心
盖世英雄少女心 2020-11-30 02:36

Is there any method to dynamic filter events on client side in fullcalendar? When I get events from server (json_encoded) I assign my own parameter \"school_id\" to every ev

4条回答
  •  感动是毒
    2020-11-30 03:15

    There is solution. I hope this help to someone else.

    jQuery("#school_selector").change(function(){
        filter_id = $(this).val();
        if (filter_id == 'all') {
            $("#eventwrapper").fadeOut();
            $('#mycalendar').fullCalendar ('removeEvents');
            var start_source1 = {
                    type:'POST',
                    data: {school_id:'all',filter:'false'},
                    url: '../../ajax/calendar/get_high_season_events.php',
                    backgroundColor: 'red'
            };
            var start_source2 = {
                    type:'POST',
                    data: {school_id:'all',filter:'false'},
                    url: '../../ajax/calendar/get_middle_season_events.php',
                    backgroundColor: 'orange'
            };
            var start_source3 = {
                    type:'POST',
                    data: {school_id:'all',filter:'false'},
                    url: '../../ajax/calendar/get_low_season_events.php',
                    backgroundColor: 'green'
            };
            $('#mycalendar').fullCalendar('addEventSource', start_source1);
            $('#mycalendar').fullCalendar('addEventSource', start_source2);
            $('#mycalendar').fullCalendar('addEventSource', start_source3);
        }else{
            $("#eventwrapper").fadeIn();
            $('#mycalendar').fullCalendar ('removeEvents');
            var start_source1 = {
                    type:'POST',
                    data: {school_id:$("#school_selector").val(),filter:'true'},
                    url: '../../ajax/calendar/get_high_season_events.php',
                    backgroundColor: 'red'
            };
            var start_source2 = {
                    type:'POST',
                    data: {school_id:$("#school_selector").val(),filter:'true'},
                    url: '../../ajax/calendar/get_middle_season_events.php',
                    backgroundColor: 'orange'
            };
            var start_source3 = {
                    type:'POST',
                    data: {school_id:$("#school_selector").val(),filter:'true'},
                    url: '../../ajax/calendar/get_low_season_events.php',
                    backgroundColor: 'green'
            };
            $('#mycalendar').fullCalendar('addEventSource', start_source1);
            $('#mycalendar').fullCalendar('addEventSource', start_source2);
            $('#mycalendar').fullCalendar('addEventSource', start_source3);
        }//if
    

提交回复
热议问题