mirror of
https://github.com/wassname/fullcalendar.git
synced 2026-06-27 16:10:13 +08:00
152 lines
3.7 KiB
Plaintext
152 lines
3.7 KiB
Plaintext
|
|
events (as a json feed)
|
|
=======================
|
|
|
|
A URL of a JSON feed that the calendar will fetch [Event Objects](Event_Object) from.
|
|
|
|
FullCalendar will visit the URL whenever it needs new event data.
|
|
This happens when the user clicks prev/next or changes views.
|
|
FullCalendar will determine the date-range it needs events for and will
|
|
pass that information along in GET parameters.
|
|
|
|
The GET parameter names will be determined by the [startParam]() and [endParam]() options.
|
|
(`"start"` and `"end"` by default).
|
|
|
|
The value of the parameters will always be UNIX timestamps (seconds since 1970).
|
|
|
|
Consider the following script:
|
|
|
|
$('#calendar').fullCalendar({
|
|
events: '/myfeed.php'
|
|
});
|
|
|
|
Here is a URL that FullCalendar might visit:
|
|
|
|
`/myfeed.php?start=1262332800&end=1265011200&_=1263178646`
|
|
|
|
The `_` parameter is automatically inserted to prevent the browser from
|
|
caching the result ([more below](#caching)).
|
|
|
|
If you need to access a feed that is in a different domain, you can use JSONP
|
|
with a `?` in your URL (see the JSONP discussion in [$.ajax](http://api.jquery.com/jQuery.ajax/)).
|
|
|
|
Extended Form
|
|
-------------
|
|
|
|
Since version 1.5, you are able to specify [Event Source options](Event_Source_Object#options).
|
|
This often comes in handy when you are using the [eventSources]() option to
|
|
specify multiple event sources and you want certain options to only apply to certain sources.
|
|
However, to do this, you must write things a little differently:
|
|
|
|
$('#calendar').fullCalendar({
|
|
|
|
eventSources: [
|
|
|
|
// your event source
|
|
{
|
|
url: '/myfeed.php', // use the `url` property
|
|
color: 'yellow', // an option!
|
|
textColor: 'black' // an option!
|
|
}
|
|
|
|
// any other sources...
|
|
|
|
]
|
|
|
|
});
|
|
|
|
A list of general Event Source options can be found [here](Event_Source_Object#options).
|
|
<span id='options'>However, there are additional options that apply specifically to JSON feeds:</span>
|
|
|
|
<table>
|
|
<tr>
|
|
<th>
|
|
startParam
|
|
</th>
|
|
<td markdown='1'>
|
|
Sets the [startParam]() option, but only for this source.
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>
|
|
endParam
|
|
</th>
|
|
<td markdown='1'>
|
|
Sets the [endParam]() option, but only for this source.
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
jQuery $.ajax options
|
|
---------------------
|
|
|
|
You can also specify any of the [jQuery $.ajax](http://api.jquery.com/jQuery.ajax/) options within the same object!
|
|
This allows you to easily pass additional parameters to your feed script, as well as
|
|
listen to ajax callbacks:
|
|
|
|
$('#calendar').fullCalendar({
|
|
|
|
eventSources: [
|
|
|
|
// your event source
|
|
{
|
|
url: '/myfeed.php',
|
|
type: 'POST',
|
|
data: {
|
|
custom_param1: 'something',
|
|
custom_param2: 'somethingelse'
|
|
},
|
|
error: function() {
|
|
alert('there was an error while fetching events!');
|
|
},
|
|
color: 'yellow', // a non-ajax option
|
|
textColor: 'black' // a non-ajax option
|
|
}
|
|
|
|
// any other sources...
|
|
|
|
]
|
|
|
|
});
|
|
|
|
Here is the same example, but using the single-source `events` option instead:
|
|
|
|
$('#calendar').fullCalendar({
|
|
|
|
events: {
|
|
url: '/myfeed.php',
|
|
type: 'POST',
|
|
data: {
|
|
custom_param1: 'something',
|
|
custom_param2: 'somethingelse'
|
|
},
|
|
error: function() {
|
|
alert('there was an error while fetching events!');
|
|
},
|
|
color: 'yellow', // a non-ajax option
|
|
textColor: 'black' // a non-ajax option
|
|
}
|
|
|
|
});
|
|
|
|
Caching
|
|
-------
|
|
|
|
<span id='caching'></span>
|
|
By default, FullCalendar will insert a `_` parameter into the URL of the request to prevent
|
|
the browser from caching the response.
|
|
FullCalendar achieves this internally by setting the $.ajax parameter to `false`.
|
|
|
|
If you would like to counteract this and prevent the `_` parameter, you can set the `cache` option to `true`:
|
|
|
|
|
|
$('#calendar').fullCalendar({
|
|
|
|
events: {
|
|
url: '/myfeed.php',
|
|
cache: true
|
|
}
|
|
|
|
});
|
|
|