Javascript 如何在 fullcalendar 中禁用拖放

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3514689/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 04:58:37  来源:igfitidea点击:

How do I disable drag and drop in fullcalendar

javascriptjqueryfullcalendar

提问by Arial

I am using FullCalendar throughout my project and i need to display it in one area of my site where events are not draggable but to remain highlighted in the month view. Any ideas please.

我在整个项目中都使用 FullCalendar,我需要在我网站的一个区域显示它,在该区域中事件不可拖动但在月视图中保持突出显示。请有任何想法。

回答by Scott Greenfield

I know this is an old question, but nobody has answered this correctly, so here you go...

我知道这是一个老问题,但没有人正确回答这个问题,所以你去吧......

$('#example').fullCalendar({
    disableDragging: true
});

回答by JochemQuery

DisableDragging is replaced by: eventStartEditable (since version 1.6.3)

DisableDragging 被替换为:eventStartEditable(自 1.6.3 版起)

http://arshaw.com/fullcalendar/docs/removed/disableDragging/

http://arshaw.com/fullcalendar/docs/removed/disableDragging/

回答by Dilpreet singh

Check the code below:

检查下面的代码:

set editable false will disable dragging.

set editable false 将禁用拖动

$('#calendar').fullCalendar({

editable: false,

});

回答by theycallmemorty

You just need to set the disableDragging optionto true when initializing your calendar.

您只需要在初始化日历时将disableDragging 选项设置为 true。

$('#calendar').fullCalendar({
    disableDragging = true
});

回答by user5073874

$('#calendar').fullCalendar({
    editable: false
});

回答by LakiGeri

In v2 & v3 there is a new expression for this: eventStartEditablewhat should be set to false, for disabling drag.

在 v2 和 v3 中,有一个新的表达式:eventStartEditablewhat should set to false,用于禁用拖动。

Furthermore if you want to disable the "drop" (e.g.: from other div) you should set droppableto falseas well.

此外,如果您想禁用“放置”(例如:来自其他 div),您也应该将droppable设置false为。

回答by user1477388

To disable event drag/drop conditionally (on a per-event basis) you can use the eventAllowoption when initializing the fullcalendar object.

要有条件地禁用事件拖/放(基于每个事件),您可以eventAllow在初始化 fullcalendar 对象时使用该选项。

eventAllow: function(dropLocation, draggedEvent) {
  if (draggedEvent.id === '999') {
    return dropLocation.start.isAfter('2016-01-01'); // a boolean
  }
  else {
    return true; // or return false to disallow
  }
}

Reference: https://fullcalendar.io/docs/eventAllow

参考:https: //fullcalendar.io/docs/eventAllow