最近我在工作中被要求修改现有模块,日历,他们希望我为其添加过滤器,日历处理的事件是评估,生日和公告。
我有一个下拉菜单,当用户选择日历评估将消失的选项并且仅带来所选ID的评估时,该菜单具有特定ID。我的问题是我无法进行选定的身份评估,因为我不知道具体如何。执行此操作的人不再在公司,我无法联系。
这是页面加载时日历的创建方式:
calendarDiv = $('#calendar')
$(document).on 'click', '#create-button', (e) ->
$(this).hide()
$(document).on 'click', '#update-button', (e) ->
$(this).hide()
remove_hidden_modals()
fetch_event()
# page is now ready, initialize the calendar...
date = new Date()
d = date.getDate()
m = date.getMonth()
y = date.getFullYear()
calendarDiv.fullCalendar
dayNamesShort: ["D", "L", "M", "M", "J", "V", "S"]
firstDay: 1
monthNames: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"]
buttonText:
today: "Hoy"
eventSources: [
url: "/calendar/events/"
className: "school"
,
url: "/calendar/evaluations/"
className: "evaluation"
,
url: "/calendar/employees_birthdays/"
className: "staff-birthday"
,
url: "/calendar/students_birthdays/"
className: "birthday"
]
loading: (isCalendarLoading) ->
if (isCalendarLoading)
calendarDiv.find('.fc-header-center').append('#{loader_html}')
else
calendarDiv.find('.fc-header-center').find('.ajax-loader').remove()
# put your options and callbacks here
timeFormat: "h:mm t{ - h:mm t} "
dragOpacity: "0.5"
#http://arshaw.com/fullcalendar/docs/event_ui/eventDrop/
eventDrop: (event, dayDelta, minuteDelta, allDay, revertFunc) ->
event.ignoreTimeZone = true
updateEvent event
# http://arshaw.com/fullcalendar/docs/event_ui/eventResize/
eventResize: (event, dayDelta, minuteDelta, revertFunc) ->
updateEvent event
现在,当有人在下拉菜单中选择一个选项时会触发:
$(document).ready ->
selected_course = ''
$('#school_courses').on 'change', ->
selected_course = document.getElementById("school_courses")
selected_course = selected_course.options[selected_course.selectedIndex].value
allEvents = $('#calendar').fullCalendar('clientEvents');
userEventIds= [];
has_new_events = false
$.each allEvents, (index, value) ->
if value.url != undefined
if value.url.search( 'evaluation_info' ) > 0
userEventIds.push value.id
has_new_events = true
$.each userEventIds, (index, value) ->
$('#calendar').fullCalendar( 'removeEvents', value);
这里我删除了所有评估,并尝试仅带有具有所选ID的那些。我在想是否有办法使用事件源数组,比如
$('#calendar').fullcalendar('renderEvent', eventSources: [
url: "/calendar/evaluations/" + selected_course
className: "evaluation"
])
但这不起作用。
我该怎么办?
谢谢。