私はFullcalendarプロジェクトに複数の選択フィルタを設定しました。私はJSONでいくつかのイベント値でフィルタリングできますが、フィルタリングするにはclassName
で取得できません。classNameによるFullcalendarフィルタ
私が間違っていることを誰かに教えてもらえますか?
ここに私が使用しているコードと、問題を複製するhere is a jsfiddleがあります。
<select id="type_selector">
<option value="all">All types</option>
<option value="university">University</option>
<option value="polytech">Polytech</option>
<option value="highschool">High School</option>
</select>
<select id="state_selector">
<option value="all">All types</option>
<option value="CA">California</option>
<option value="MI">Michigan</option>
<option value="VT">Vermont</option>
</select>
<select id="color_selector">
<option value="all">All colors</option>
<option value="red">Red schools</option>
<option value="orange">Orange schools</option>
<option value="green">Green schools</option>
</select>
<div>
<div id='calendar'></div>
</div>
<script>
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
defaultView: 'agendaWeek',
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
selectable: true,
selectHelper: true,
year: 2016,
month: 08,
date: 25,
slotMinutes: 15,
editable: true,
events: [{
title: 'Michigan University',
start: '2016-09-26',
type: 'university',
state: 'MI',
className: 'red'
}, {
title: 'California Polytechnic',
start: '2016-09-27',
type: 'polytech',
state: 'CA',
className: 'orange'
}, {
title: 'Vermont University',
start: '2016-09-28',
type: 'university',
state: 'VT',
className: 'red'
}, {
title: 'Michigan High School',
start: '2016-09-29',
type: 'highschool',
state: 'MI',
className: 'green'
}, {
title: 'Vermont High School',
start: '2016-09-30',
type: 'highschool',
state: 'VT',
className: 'green'
}, {
title: 'California High School',
start: '2016-09-30',
type: 'highschool',
state: 'CA',
className: 'green'
}],
eventRender: function eventRender(event, element, view) {
return ['all', event.type].indexOf($('#type_selector').val()) >= 0
&& ['all', event.state].indexOf($('#state_selector').val()) >= 0
&& ['all', event.className].indexOf($('#color_selector').val()) >= 0
}
});
$('#type_selector').on('change', function() {
$('#calendar').fullCalendar('rerenderEvents');
})
$('#state_selector').on('change', function() {
$('#calendar').fullCalendar('rerenderEvents');
})
$('#color_selector').on('change', function() {
$('#calendar').fullCalendar('rerenderEvents');
})
});
</script>
大変ありがとうございます@ミルズ!私は "myClass"のようなjson中性配列プロパティを使用し、FullCalendarで "className"を呼び出すことができるのだろうかと思っていましたか?または、私は公式のDOMプロパティ "className"を使用し、その値をニュートラル変数 "myClass"に代入して、リターンルーチンからニュートラル変数を呼び出すことはできますか?私はデータ入力プロセスを可能な限り短く保つよう努めています。 – lbriquet
@lbriquetバックグラウンドカラーを失うため、ニュートラルプロパティだけを使用することはできません。ただし、スタイルの 'className'を設定し、フィルタリングのために' myClass'を設定することができます。 [この更新されたフィドル](http://jsfiddle.net/milz/kzfwro22/4/)を見てください –
あなたの助けをもう一度ありがとう@ミルズ!私がしたいことは、var myClass = event.classNameのようなことをして、return ['all'、event.myClass] .indexOf($( '#color_selector')。val() )> = 0これは可能ですか? – lbriquet