FullCalendar: How to stop dragging custom events?

2020-07-11 05:18发布

Can anybody tell me how to stop dragging / resizing the events where event.id > 100? Only those events should be non draggable.

Updated with Code Sample:

eventRender: function(event, element) {
    if (event.id > 100) {
        event.disableDragging();
        event.disableResizing();
    }

    element.qtip({
        content: GetEventToolTip(event),
        position: { corner: { tooltip: 'bottomLeft', target: 'topMiddle'} },
        style: {
            border: {
                width: 1,
                radius: 5
            },
            padding: 5,
            textAlign: 'left',
            tip: false,
            name: event.iscustom == 'True' ? 'cream' : 'dark'
        }
    });
}

Thanks.

12条回答
兄弟一词,经得起流年.
2楼-- · 2020-07-11 06:06
eventRender: function(event, element) {
    if (event.id.indexOf("IDENTIFYING_STRING") == -1) 
    {
        event.editable = false;
    }                       
}
查看更多
Juvenile、少年°
3楼-- · 2020-07-11 06:06

I did not have success with the methods shown here. I ended up hacking fullcalendar.js to add a noDragging option for events, which was actually extremely easy:

original:

function isEventDraggable(event) {
    return isEventEditable(event) && !opt('disableDragging');
}

changed it to:

function isEventDraggable(event) {
    return isEventEditable(event) && !opt('disableDragging') && !event.noDragging;
}

Just added the check for event.noDragging.

查看更多
淡お忘
4楼-- · 2020-07-11 06:09

You have to hack fullcalendar.js

uncomment lines

t.isEventDraggable = isEventDraggable;
t.isEventResizable = isEventResizable;

replace functions:

function isEventDraggable(event) {
         return isEventEditable(event) && !opt('disableDragging') &&
            !event.disableDragging;
}


function isEventResizable(event) { // but also need to make sure the seg.isEnd == true
         return isEventEditable(event) && !opt('disableResizing') &&
            !event.disableResizing; 
}

Now you can enable/disable resize and dragging for every event as you like.

查看更多
戒情不戒烟
5楼-- · 2020-07-11 06:09

Use these tags when creating your fullcalendar to disable dragging or resizing.

**>  $('#calendar').fullCalendar({
> 
>    editable: false,
> 
> //the rest of your code... }**
查看更多
聊天终结者
6楼-- · 2020-07-11 06:11

This is the best solution:

$('#calendar').fullCalendar({
    disableDragging = true
});
查看更多
做自己的国王
7楼-- · 2020-07-11 06:12

in editable just write false and it wont be able to drag and drop editable: false

查看更多
登录 后发表回答