Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.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以编程方式更改事件呈现颜色_Jquery_Fullcalendar - Fatal编程技术网

jQuery FullCalendar以编程方式更改事件呈现颜色

jQuery FullCalendar以编程方式更改事件呈现颜色,jquery,fullcalendar,Jquery,Fullcalendar,我正在开发jQuery插件fullcalendar的多用户版本。每个用户都有一种独特的颜色。您可以在下拉列表中更改用户。因此,我可以为用户现有事件指定颜色 问题是,在渲染新事件时,在初始化时分配给fullCalendar的“eventColor”属性的颜色不会更改 例如,假设用户1有蓝色事件。我用“eventColor”蓝色初始化fullCalendar。当和我更改为具有黄色事件的用户2时,渲染事件仍显示蓝色事件。我希望事件从我开始拖动的那一刻起变为黄色,直到我释放事件为止 我尝试用$('.ca

我正在开发jQuery插件fullcalendar的多用户版本。每个用户都有一种独特的颜色。您可以在下拉列表中更改用户。因此,我可以为用户现有事件指定颜色

问题是,在渲染新事件时,在初始化时分配给fullCalendar的“eventColor”属性的颜色不会更改

例如,假设用户1有蓝色事件。我用“eventColor”蓝色初始化fullCalendar。当和我更改为具有黄色事件的用户2时,渲染事件仍显示蓝色事件。我希望事件从我开始拖动的那一刻起变为黄色,直到我释放事件为止

我尝试用$('.calendar')更改事件渲染颜色。fullCalendar('option','eventColor','NEW_color_HERE');但这不起作用


有人发现自己处于同样的情况并提出了解决方案吗?:)

如果更改全局颜色,请尝试
rerendervents

但是看起来您可能只想设置一个事件的
color
属性(例如,从
eventClick
),然后调用
updateEvent

这有用吗

function option(name, value) {

        if (value === undefined) {
           return options[name];
        }
        if (name == 'height' || name == 'contentHeight' || name == 'aspectRatio') {
            options[name] = value;
            updateSize();
        }
       // So I added these lines to the plugin and voila, it works like charm!
       if(name == 'eventColor') {
           options[name] = value;
       }
}
在脚本中通过

$('.calendar').fullCalendar('option', 'eventColor', '#NEW_COLOR_HERE');

以编程方式更改事件颜色的一种方法是,首先使用
clientEvents
检索事件(基于其id),更改其颜色,最后使用
updateEvent
重新呈现事件:

event = $('#full-calendar').fullCalendar('clientEvents', event_id)
event.color = 'red'
$('#full-calendar').fullCalendar('updateEvent', event)

感谢您的快速响应!重播是行不通的。如果我能在用户更改时更改全局eventColor,那将是最好的选择。calendarObject.fullCalendar('option','eventColor','#fefefe')不应该这样做吗?我了解了在释放事件并触发renderEvent回调时如何更改事件颜色。但在按住鼠标并拖动时,事件将以全局颜色渲染。