简体   繁体   English

为什么相同类型的外部元素在FullCalendar中同时重叠?

[英]Why same type of external element get overlap on the same time in FullCalendar?

I am trying to stop overlapping same id event onto the each other. 我试图停止相同的id事件相互重叠。 For ex: if I have id:1 eventName: orange so if I drag this external element onto the week's calendar and assign time of this event from 8 to 9 then another event should not be assign in this time slot 8 to 9 as it's already occupied by event 1. No matter what if it's id 1 or id 2 it should not be overlap there once it's occupied by id 1. 例如:如果我有id:1 eventName:橙色,那么如果我将此外部元素拖到一周的日历上并将该事件的时间从8分配到9,则不应在此8到9的时隙中分配另一个事件被事件1占用。无论它是id 1还是id 2,一旦被id 1占用,都不应在那里重叠。

Screenshot and this should not be happen as you can clearly see both events of same id is side by side which I DON'T WANT. 屏幕截图,这应该不会发生,因为您可以清楚地看到相同ID的两个事件是并排的,我不想。 在此处输入图片说明

You can get my code from fiddle and here is my fiddle please edit or develop new one. 您可以从小提琴中获取我的代码,这是我的小提琴,请编辑或开发新代码。 Thank you guys a lot in advanced.:) 非常感谢你们。.)

Friends, I also have one more issue apart from this main issue that if I move sunday orange event to monday. 朋友,除了这个主要问题外,我还有另外一期,如果我将周日橙色活动移至周一。 Then tuesday orange event is also move to wednesday so how to remove connections between them so only sunday orange event move to Monday and not affect to Tuesday event. 然后,周二橙色事件也移至星期三,因此如何删除它们之间的联系,因此只有周日橙色事件移至星期一,而不会影响周二事件。 Please help me guys as new to FullCalander and I couldn't find document is so useful as they should provide examples. 请帮助我,作为FullCalander的新手,我找不到文档如此有用,因为他们应该提供示例。

Fiddle 小提琴

$(document).ready(function () {


    /* initialize the external events
    -----------------------------------------------------------------*/

    $('#external-events .fc-event').each(function () {

        // store data so the calendar knows to render an event upon drop
        $(this).data('event', {
            title: $.trim($(this).text()), // use the element's text as the event title
            stick: true, // maintain when user navigates (see docs on the renderEvent method)
            id: $(this).attr('id')
        });

        // make the event draggable using jQuery UI
        $(this).draggable({
            zIndex: 999,
            revert: true, // will cause the event to go back to its
            revertDuration: 0 //  original position after the drag
        });

    });


    /* initialize the calendar
    -----------------------------------------------------------------*/

    $('#calendar').fullCalendar({
        header: {
            left: 'today',
            center: 'title',
            right: 'agendaWeek'
        },
        allDaySlot: false,
        slotEventOverlap: false,
        eventOverlap: function (stillEvent, movingEvent) {
            return stillEvent.allDay && movingEvent.allDay;
        },
        columnFormat: {
            week: 'dddd'
        },
        titleFormat: 'dddd',
        eventDrop: function (event, delta, revertFunc) {
            //inner column movement drop so get start and call the ajax function......
            console.log(event.start.format());
            console.log(event.id);

            //alert(event.title + " was dropped on " + event.start.format());

        },
        eventResize: function (event, delta, revertFunc) {
            console.log(event.id);
            console.log("Start time: " + event.start.format() + "end time: " + event.end.format());

        },
        timeFormat: 'H(:mm)',

        editable: true,
        defaultView: 'agendaWeek',
        droppable: true, // this allows things to be dropped onto the calendar
        drop: function (date) {

            //Call when you drop any red/green/blue class to the week table.....first time runs only.....
            console.log("dropped");
            console.log(date.format());
            console.log(this.id);


            // is the "remove after drop" checkbox checked?
            /*if ($('#drop-remove').is(':checked')) {
                // if so, remove the element from the "Draggable Events" list
                $(this).remove();
            }*/
        },
        eventRender: function (event, element) {

        }

    });


});

Removing the id tags from the external events should fix both issues 从外部事件中删除id标签应解决两个问题

<div class='fc-event orange'>Orange</div> <!-- removed id="1" -->
<div class='fc-event red'>Red</div>       <!-- removed id="2" -->
<div class='fc-event purple'>Purple</div> <!-- removed id="3" -->

http://jsfiddle.net/uu0jd543/ http://jsfiddle.net/uu0jd543/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM