Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在fullcalendar中的drop事件上添加背景色_Jquery_Fullcalendar - Fatal编程技术网

Jquery 在fullcalendar中的drop事件上添加背景色

Jquery 在fullcalendar中的drop事件上添加背景色,jquery,fullcalendar,Jquery,Fullcalendar,从列表中选择“主题”,然后将在“日历默认颜色显示”属性中定义的颜色放入“完整日历” 我想动态更改背景色。但问题是,如果我在eventColor中硬编码颜色名称,则颜色名称无效。如果我将颜色名称存储在变量中,并将其分配给eventColor,则颜色名称无效 ` 是一个设置选项。当日历加载时,它只使用一次—您将值赋给fullCalendar,它接受并使用该数据设置日历。之后就不再使用了 如果要为外部事件提供一些自定义数据,这些数据将在事件添加到日历时使用,可以在初始化自定义事件时执行,方法是将其添加

从列表中选择“主题”,然后将在“日历默认颜色显示”属性中定义的颜色放入“完整日历”

我想动态更改背景色。但问题是,如果我在eventColor中硬编码颜色名称,则颜色名称无效。如果我将颜色名称存储在变量中,并将其分配给eventColor,则颜色名称无效

`

是一个设置选项。当日历加载时,它只使用一次—您将值赋给fullCalendar,它接受并使用该数据设置日历。之后就不再使用了

如果要为外部事件提供一些自定义数据,这些数据将在事件添加到日历时使用,可以在初始化自定义事件时执行,方法是将其添加到项目具有的事件属性列表中:

$(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)
  color: $(this).data("color") // <-- get the colour from the data-attribute of the event
});

演示:

问题是,当我第一次将事件拖到fullcalendar时,它的工作正常。但当我将事件拖到draggable事件时,所有设置都被删除。将事件拖到draggable…我不知道这是什么意思?你试过演示吗?你认为它到底有什么问题?请描述重现您试图告诉我的任何问题的确切步骤。演示完全按照您的要求进行-当您将活动放到日历上时,它会以正确的颜色显示。如果你对代码的另一部分有单独的问题,那么接受这个答案并提出一个新的问题。它的工作原理是正确的。但是当我再次将事件放到列表中时,所有设置都消失了。这是一个输入错误:.css{'background-color':+event.color}不应该有+。感谢您的回复,但如果您拖放事件2到3次设置仍然不存在,我不知道这个完整日历设置有什么问题。设置仅在第一次起作用:
var myColor;

$('#calendar').fullCalendar({
header: {
  left: 'prev,next today',
  center: 'title',
  right: 'month,agendaWeek,agendaDay'
},
editable: true,
droppable: true,  
dragRevertDuration: 0,
drop: function() {

  if ($('#drop-remove').is(':checked')) {

    $(this).remove();
  }
  myColor = $(this).data("color");

},
eventColor:"red",
eventDragStop: function(event, jsEvent, ui, view) {

  if (isEventOverDiv(jsEvent.clientX, jsEvent.clientY)) {
    $('#calendar').fullCalendar('removeEvents', event._id);
    var el = $("<div class='' data-color='"+myColor+"' >").css({'background-color':+myColor}).appendTo('#external-events-listing').text(event.title);
    el.draggable({
      zIndex: 999,
      revert: true,
      revertDuration: 0
    });
    el.data('event', {
      title: event.title,
      id: event.id,
      stick: true
    });
  }
}
});
eventColor:myColor
$(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)
  color: $(this).data("color") // <-- get the colour from the data-attribute of the event
});