2016-11-29 13 views
0

月ごとにFullCalendarをフィルタリングする方法はありますか。そのため、ドロップダウンから特定の月を選択してイベントを読み込むことができます。フィルタJquery Fullcalendar月間

よろしく

あなたがヶ月での選択を生成して使用することができます

答えて

0

gotoDate

デモJS

<div id='caljump'> 
    <label for='months'>Jump to</label> 
    <select id='months'></select> 
</div> 
<div id='calendar'></div> 

HTML

https://jsfiddle.net/L6a5LL5b/ @

$(document).ready(function() { 
    var $months = $('#months'); 
    var $calendar = $('#calendar'); 

    $calendar.fullCalendar({ 
     viewRender: function() { 
      buildMonthList(); // update the jump list when the view changes 
     } 
    }); 

    $('#months').on('change', function() { 
     $calendar.fullCalendar('gotoDate', $(this).val()); 
    }); 

    buildMonthList(); // set initial jump list on load 

    function buildMonthList() { 
     $('#months').empty(); // clear jump list 
     var month = $calendar.fullCalendar('getDate'); 
     var initial = month.format('YYYY-MM'); // where are we? 
     month.add(-6, 'month'); // 6 months past 
     for (var i = 0; i < 13; i++) { // 6 months future 
      var opt = document.createElement('option'); 
      opt.value = month.format('YYYY-MM-01'); 
      opt.text = month.format('MMM YYYY'); 
      opt.selected = initial === month.format('YYYY-MM'); // current selection 
      $months.append(opt); 
      month.add(1, 'month'); 
     } 
    } 
}); 
+0

こんにちはsmcd ..助けていただきありがとうございます..ちょうど1つの質問..もし私が選択した月の値をコントローラクラスのメソッドに送る必要があれば、月の値か月のフォーマットはどうなるでしょう。 – learningmode

+0

私はその質問を理解しているかどうかはわかりませんが、オプション値はISO 8601形式、YYYY-MM-DDです(現在DD値では01になっていますが)。 – smcd

関連する問題