使用eventRender在fullcalendar事件内显示图像 [英] Displaying image inside a fullcalendar event with eventRender
问题描述
我试图使用 addClass
在 fc-event-inner
类中显示图像。我想用 jquery
来做到这一点,这样我就可以在不同的事件中使用不同的图像。任何人都可以告诉我为什么这不起作用?
I am trying to display an image in the fc-event-inner
class using addClass
. I want to do this with jquery
so I can use different images in different events. Can anyone tell me why this doesn't work?
calendar.fullCalendar('renderEvent', {
title: title,
start: start,
end: end,
allDay: allDay,
eventRender: function(copiedEventObject,element) {
element.find('.fc-event-inner').css('background-image',"url(icons/kalender_medicin_100px.png)")
},
className: '.fc-event-inner'
});
推荐答案
您应该指定 eventRender
在fullCalendar配置中,不能通过 renderEvent
方法传递它。
You should specify the eventRender
in the fullCalendar configuration, not pass it through the renderEvent
method.
$('#calendar').fullCalendar({
eventRender: function(copiedEventObject,element) {
var icon = $(document.createElement('div'));
icon.css('background-image',"url(icons/kalender_medicin_100px.png)");
element.find('.fc-event-title').html(icon + copiedEventObject.title);
}
});
如果您只想将图标添加到拖动的事件中,您可以将自定义属性传递给事件数据像这样:
If you want to add icons only to the dragged events you can pass an custom property to the event data like so:
calendar.fullCalendar('renderEvent', {
//...
isCustom: true,
//...
}
现在您可以检查如果事件在 eventRender
事件中具有定制属性。
Now you can check if the event has the custom property in the eventRender
event.
eventRender: function(copiedEventObject,element) {
if(copiedEventObject.isCustom){
//...
}
这篇关于使用eventRender在fullcalendar事件内显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!