I'm using FullCalendar to add an event when a day is clicked, but it's not working. I can't see a new event on the calendar, but I can see the "clicked" message I set. Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Schedule </title>
开发者_高级运维
<link rel="stylesheet" type="text/css" href="fullcalendar.css" />
<style type="text/css">
</style>
<script type="text/javascript" src="jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="fullcalendar.js"></script>
<script type="text/javascript" src="jquery-ui-1.8.11.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#schedule').fullCalendar({
dayClick: function(date, allDay, jsEvent, view) {
$('#schedule').fullCalendar({'addEventSource', {title: "lesson", start: date}});
alert("clicked");
}})
});
</script>
</head>
<body>
<div id="schedule">
</div>
</body>
</html>
firebug says invalid property id on the line with addEventSource.
You seem to be a little bracket heavy, try changing
.fullCalendar({'addEventSource', {title: "lesson", start: date}});
to
.fullCalendar('addEventSource', {title: "lesson", start: date});
If that still doesn't work try this...
.fullCalendar('addEventSource', [{title: "lesson", start: date}]);
Which is basically making the event an array instead of a single object.
Let me know how it goes!
精彩评论