2010-01-16 23:29:18 +01:00
|
|
|
|
|
|
|
eventClick
|
|
|
|
==========
|
|
|
|
|
|
|
|
Triggered when the user clicks an event.
|
|
|
|
|
|
|
|
<div class='spec' markdown='1'>
|
2010-01-18 05:20:01 +01:00
|
|
|
function( *event*, *jsEvent*, *view* ) { }
|
2010-01-16 23:29:18 +01:00
|
|
|
</div>
|
|
|
|
|
2010-01-18 05:20:01 +01:00
|
|
|
`event` is an [Event Object](../event_data/Event_Object) that holds the event's information (date, title, etc).
|
2010-01-16 23:29:18 +01:00
|
|
|
|
|
|
|
`jsEvent` holds the native JavaScript event with low-level information such as click coordinates.
|
|
|
|
|
|
|
|
`view` holds the current [View Object](../views/View_Object).
|
|
|
|
|
|
|
|
Within the callback function, `this` is set to the event's `<div>` element.
|
|
|
|
|
|
|
|
Here is an example demonstrating all these variables:
|
|
|
|
|
|
|
|
$('#calendar').fullCalendar({
|
|
|
|
eventClick: function(calEvent, jsEvent, view) {
|
|
|
|
|
|
|
|
alert('Event: ' + calEvent.title);
|
|
|
|
alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
|
|
|
|
alert('View: ' + view.name);
|
|
|
|
|
2010-01-18 05:20:01 +01:00
|
|
|
// change the border color just for fun
|
|
|
|
$(this).css('border-color', 'red');
|
2010-01-16 23:29:18 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Return Value
|
|
|
|
------------
|
|
|
|
|
|
|
|
Normally, if the [Event Object](../event_data/Event_Object) has its `url` property set, a click on the event
|
|
|
|
will cause the browser to visit the event's url (in the same window/tab).
|
|
|
|
Returning `false` from within your function will prevent this from happening.
|
|
|
|
|
2010-01-18 05:20:01 +01:00
|
|
|
Often, developers want an event's `url` to open in a different tab or a popup window.
|
2010-01-16 23:29:18 +01:00
|
|
|
The following example shows how to do this:
|
|
|
|
|
|
|
|
$('#calendar').fullCalendar({
|
2010-01-18 05:20:01 +01:00
|
|
|
events: [
|
|
|
|
{
|
|
|
|
title: 'My Event',
|
|
|
|
start: '2010-01-01',
|
|
|
|
url: 'http://google.com/'
|
|
|
|
}
|
|
|
|
// other events here
|
|
|
|
],
|
|
|
|
eventClick: function(event) {
|
|
|
|
if (event.url) {
|
|
|
|
window.open(event.url);
|
2010-01-16 23:29:18 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
The `window.open` function can take [many other options](http://www.w3schools.com/jsref/met_win_open.asp).
|
2010-01-18 05:20:01 +01:00
|
|
|
|