You didn't actually say precisely what is going wrong, but I can see that what you're doing with your "eventClick" callback doesn't make any sense. It will try to generate a location.href
command for every event in your query results. These will all be added to the JavaScript, one after another, as a series of consecutive commands. But eventClick
is only defined once....so this means it will try to navigate to all your events simultaneously.
To add to this, you've put the PHP code in the wrong place, so you're ending with some invalid JavaScript. The finished JS will look something like this:
eventClick: function(calEvent, jsEvent, view)
{ location.href = "update_task.php?id=1"; }
{ location.href = "update_task.php?id=2"; }
{ location.href = "update_task.php?id=3"; }
{ location.href = "update_task.php?id=4"; }
{ location.href = "update_task.php?id=5"; }
which is clearly nonsense, and will probably generate a syntax error.
Even if you did it correctly, you'd end up with the finished JavaScript code looking like something this:
eventClick: function(calEvent, jsEvent, view) {
location.href = "update_task.php?id=1";
location.href = "update_task.php?id=2";
location.href = "update_task.php?id=3";
location.href = "update_task.php?id=4";
location.href = "update_task.php?id=5";
}
Clearly this a) isn't useful and b) won't work anyway. You'll just always end up navigating to the first event, since that'll be the first location.href command which gets printed.
The conclusion is: you can't implement this functionality with PHP, because at the time when PHP is running and you're generating your page on the server, you have no way of knowing which event is going to be clicked on, so you can't set the ID in advance like this.
Luckily, the eventClick callback provides the calEvent
parameter, containing details of the event which was clicked on. Assuming that, in your JSON event data, you supply the id
of each event to fullCalendar, then you can use this value instead to build the URL of the specific event which has been clicked:
eventClick: function(calEvent, jsEvent, view) {
location.href = "update_task.php?id=" + calEvent.id;
}