user789122
user789122

Reputation: 480

FullCalendar and multiple event sources

I have a couple of json feeds that I'd like to display on the calendar.

Looking at the docs there does seem some explanation, but no example of having more than 1 json feed.

I have the following:

var source = Array();
source[0] = '/feed1.php';
source[1] = '/feed2.php';
eventSources: [
  source[0],
  source[1]
]

This displays the events fine and I can seem them on my calendar

But how would I differentiate between them in terms of colors?

Thanks

Upvotes: 4

Views: 16184

Answers (1)

Brian Showalter
Brian Showalter

Reputation: 4349

You can use the extended form of event sources to give each source its own color. In the code below, "color" is the event background color and "textColor" is the color of the event text.

$('#calendar').fullCalendar({
  header: {
    left: 'prev,next',
    center: 'title',
    right: 'today'
  },

  eventSources: [
    {
      url: '/feed1.php',
      color: 'yellow',
      textColor: 'black'
    },
    {
      url: '/feed2.php',
      color: 'blue',
      textColor: 'white'
    }
  ]
});

Here's a JSFiddle that uses this method: http://jsfiddle.net/emcw5/4/.

Upvotes: 11

Related Questions