fullCalendar在同一天发现附加事件? [英] fullCalendar finding addtional events in the same day?

查看:329
本文介绍了fullCalendar在同一天发现附加事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在同一天检测其他事件。我希望能够做的是找到eventClass X的事件是否与eventClass Y的丢弃事件同一天存在。如果不是会警告用户,eventClass X不存在,否则允许用户

I need to detect other events in the same day. What I hope to be able to do, is find if an event of eventClass X exists in the same day as a dropped event of eventClass Y. If not it would warn the user, that an eventClass X does not exist, else allow the user to drop the event.

这是可能吗?

推荐答案

在浏览文档和一些实验后,我使用clientEvents方法得到一个解决方案:

Well after probing around in the docs and a little experimenting, I arrived at a solution using the clientEvents method:

  eventDrop: function( event, dayDelta, minuteDelta, allDay, 
                       revertFunc, jsEvent, ui, view )
        {
            // see if its a concept class event
            if (event.className == 'conceptclass'){
                // create a new date object from the start of the event 
                var eventDate = new Date(event.start);
                // zero its time 
                eventDate.setHours(0);
                eventDate.setMinutes(0);
                eventDate.setSeconds(0);
                eventDate.setMilliseconds(0);

                // now find all the events currently displayed in the calendar
                var pulledEvents = $('#calendar').fullCalendar( 'clientEvents');
                var meetingDay = false; // until a meeting is found 

                for(var i = 0; i < pulledEvents.length; i++){
                    // if the pulled event is of the meeting class 
                    if(pulledEvents[i].className == 'meetingclass'){
                        // create a new date object from the start of the pulled event 
                        var testEventDate = new Date(pulledEvents[i].start);
                         // zero its time for comparison 
                        testEventDate.setHours(0);
                        testEventDate.setMinutes(0);
                        testEventDate.setSeconds(0);
                        testEventDate.setMilliseconds(0);

                        // if meeting event found in the day
                        // OK a little wierdness here, even though the dates were equal 
                        // they would not return a valid comparison.  So I get the time value.
                        if(testEventDate.getTime() == eventDate.getTime()){
                           meetingDay = true;
                           break;
                        }
                    }
            }
            if(!meetingDay){
                 alert("Tried to drop a Concept into Day without Scheduled Review Meeting!");
                 revertFunc(); // back to where it came!
            }       
      }

这篇关于fullCalendar在同一天发现附加事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆