fullcalendar/docs/events-and-sources.txt

121 lines
4.2 KiB
Plaintext
Raw Normal View History

2009-09-14 00:25:49 +02:00
2009-09-14 05:36:27 +02:00
.. _event-sources:
Event Sources
=============
2009-09-14 00:25:49 +02:00
The following options determine *how* events get on the calendar:
2009-09-14 05:36:27 +02:00
**events**: Array/String/Function
An array of :ref:`CalEvents <CalEvent>` can be used to hardcode events into the
calendar.
Or, a URL can be provided. This URL should return JSON for an array of
:ref:`CalEvents <CalEvent>`. GET parameters, determined by the
``startParam`` and ``endParam`` options, will be inserted into the URL.
These parameters indicate the UNIX timestamp of the start of the first
visible day (inclusive) and the end of the last visible day (exclusive).
Or, a function can be provided for custom fetching. The function is
queried every time event data is needed. The function is passed a ``start``
Date object, an ``end`` Date object, and a function to be called when
fetching is complete. Here is the general form::
events: function(start, end, callback) {
2009-09-14 00:25:49 +02:00
2009-09-14 05:36:27 +02:00
// do some asynchronous ajax
$.getJSON("/myscript",
{
start: start.getTime(),
end: end.getTime()
},
function(result) {
// format the result into an array of CalEvents
// (not seen here)
2009-09-14 00:25:49 +02:00
2009-09-14 05:36:27 +02:00
// then, pass the CalEvent array to the callback
callback(calevents);
});
}
2009-09-14 00:25:49 +02:00
2009-09-14 05:36:27 +02:00
**eventSources**: Array
Similar to the ``events`` options, except one may specify *multiple* sources.
For example, one may specify an array of JSON URL's, an array of custom
functions, an array of hardcoded event arrays, or any combination.
2009-09-14 00:25:49 +02:00
2009-09-14 05:36:27 +02:00
**startParam**: String, *Default*: ``'start'``
A GET parameter of this name will be inserted into the URL when fetching
events from a JSON script. The value of this GET parameter will be a UNIX
timestamp denoting the start of the first visible day (inclusive).
2009-09-14 00:25:49 +02:00
2009-09-14 05:36:27 +02:00
**endParam**: String, *Default*: ``'end'``
A GET parameter of this name will be inserted into the URL when fetching
events from a JSON script. The value of this GET parameter will be a UNIX
timestamp denoting the end of the last visible day (exclusive).
2009-09-14 00:25:49 +02:00
2009-09-14 05:36:27 +02:00
**cacheParam**: String, *Default*: ``'_'``
When using a JSON url, a parameter of this name will
automatically be inserted into the URL to prevent the browser from
caching the response. The value will be the current millisecond time.
2009-09-14 00:25:49 +02:00
2009-09-14 05:36:27 +02:00
.. _CalEvent:
2009-09-14 00:25:49 +02:00
CalEvent Objects
================
A CalEvent is a data structure that frequents FullCalendar's API. It is the
2009-09-14 05:36:27 +02:00
standardized currency used in :ref:`event-sources`. It is also passed to various
:ref:`Triggered Actions <triggered-actions>`. Here are the properties of a
2009-09-14 00:25:49 +02:00
CalEvent:
2009-09-14 05:36:27 +02:00
**id**: Integer/String
Uniquely identifies the given event. Instances of repeating events should
all have the same id.
2009-09-14 00:25:49 +02:00
2009-09-14 05:36:27 +02:00
**title**: String
The text on an event's element
2009-09-14 12:28:23 +02:00
**allDay**: Boolean (optional, defaults to ``true``)
Determines whether the start-date and end-date's times should be ignored.
If ``true``, times will be ignored. If ``false``, times will be considered,
displaying them on each event (like the text '3pm').
2009-09-14 00:25:49 +02:00
2009-09-14 05:36:27 +02:00
**date**: Date
Alias for ``start``
2009-09-14 00:25:49 +02:00
2009-09-14 05:36:27 +02:00
**start**: Date
A javascript Date object indicating the date/time an event begins.
In an :ref:`Event Source <event-sources>`, for convenience,
one can also use a string in IETF format (ex: "Wed, 18 Oct 2009 13:00:00 EST"),
a string in ISO8601 format (ex: "2009-11-05T13:15:30Z") or an integer
UNIX timestamp.
**end**: Date (optional)
A javascript Date object indicating the date/time an event ends.
2009-09-14 12:28:23 +02:00
As with ``start``, IETF and ISO8601 strings can be used.
2009-09-14 00:25:49 +02:00
2009-09-14 12:28:23 +02:00
**If an event is all-day...**
2009-09-14 05:36:27 +02:00
2009-09-14 12:28:23 +02:00
the end date is *inclusive*. This means an event with ``start`` *Nov 10* and
``end`` *Nov 12* will span *3 days* on the calendar.
**If an event is NOT all-day...**
the end date is *exclusive*. This is only a gotcha when your ``end`` has time 00:00.
It means your event ends on midnight, and it will *not* span through the next day.
2009-09-14 00:25:49 +02:00
2009-09-14 05:36:27 +02:00
**className**: String/Array (optional)
A CSS class (or array of classes) that will be attached to this event's
element.
**editable**: Boolean (optional)
Overrides the master ``editable`` option for this single event.
**source**: Array/String/Function (automatically populated)
A reference to the original array, JSON URL, or function the event
came from. Do not worry about populating this value, FullCalendar will
do this automatically.