well, I want to set a different color for each event. Basically that’s it
I’m reading events from an Ajax call
Thanks
EDIT: I don’t want to wait 8 hours for answer my own question
first of all, my apologize for not include code example on my answer, but thanks to Brandom who guide me to find my answer 😛
So, here is my .js file which has an Ajax call to my events:
$(document).ready(function() {
$('#calendar').fullCalendar({
events: {
url:'http://myhost/mysite/ajax/',
type: 'POST',
data:{ trigger: 'eventos' },
error: function() { alert('there was an error while fetching events!'); }
}
});
}
then, in my .php file who receives my ajax call I have this:
<?
if($_POST['trigger'] == 'eventos'){
$eventos = new WP_Query();
$eventos->query(array(
'post_type' => 'evento'
)
);
$eventdata = array();
while($eventos->have_posts()) : $eventos->the_post();
$elem = array(
'id' => $post->ID,
'title' => $post->post_title,
'start' => get('evento_fecha_inicio',1,1,$post->ID),
'end' => get('evento_fecha_termino',1,1,$post->ID),
'allDay' => 'false',
'color' => '#'.rand(000000,999999), //this is what I'm was looking for!
);
$eventdata[] = $elem;
endwhile;
echo json_encode($eventdata);
}
?>
(the ‘get’ functions corresponds to magicfields‘ functions). So there it is, with a rand(); in the color value I can generate a random color for each event element
(sorry for my english)
If you’re using FullCalendar v1.5 you can set the
color,backgroundColor,borderColorandtextColorproperties of the Event Object