如何将每个事件与背景的不同颜色相关联?
我使用管理界面
记录了许多事件我的函数(视图模块)使用json.dumps(event_list)返回记录 我有视觉文件
$('#calendar').fullCalendar({
header: {
left: 'prev,next today, save',
center: 'title',
right: 'month,agendaWeek,agendaDay,agendaFourDay'
},
'defaultView': 'month',
editable: true,
views: {
agendaFourDay: {
type: 'agenda',
duration: { days: 4 },
buttonText: '4 day'
}
},
events: '/events_json/',
eventClick: function(calEvent, jsEvent, view) {
document.location.href = '/admin/notes/event/'+ calEvent.id + '/';
},
dayClick: function(date, allDay, jsEvent, view) {
document.location.href = '/admin/notes/event/add/';
},
},
});
});
我试图添加:
eventRender: function (event, element, view)
{
var date = new Date();
if (event.start >= date) {
element.css('background-color', '#000');
}
}
但是element.css没有工作......
我的模特是:
class Event(models.Model):
title = models.CharField(_('titre'), max_length=100)
start = models.DateTimeField(_('debut'))
end = models.DateTimeField(_('fin'))
is_cancelled = models.BooleanField(_('Annulation?'), default=False, blank=True)
calendar = models.ForeignKey(Calendar, verbose_name=_('categorie'))
user = models.ForeignKey(User, default=None, blank= True, null = True, verbose_name=_('utilisateur'))
description = models.TextField(_('description'), blank=True)
frequency = models.CharField(_(u"Occurence(s) :"), choices=freqs, max_length=10, default=0)
fin = models.IntegerField(_(u"Fin après un nombre d'occurence(s) de :"), choices=CYCLES, default=0)
rep = models.IntegerField(_(u"décalage (jours) de :"), choices=DELAY, default=0)
activated = models.BooleanField(verbose_name='Activation ?', default=False, blank=True)
def __unicode__(self):
return u'%s' % self.title
我通过事件阅读所有事件:' / events_json /'
如果我输入javascript文件:
var date = new Date();
if (event.start <= date) {
document.write(event);
我有:[object Object] [object Object]
也许,这是element.css的问题(&#39;背景颜色&#39;,&#39;#000&#39;);
该怎么办?