I’m trying to format the ‘date’ parameter in the fullCalendar dayClick so it’s passed to a url which can be interpreted by my routing to redirect to the correct controller. Here is my js;
<script type="text/javascript">
$(document).ready(function () {
$('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: ''
},
defaultView: 'month',
editable: false,
allDay: true,
dayClick: function (date, allDay, jsEvent, view) {
if (allDay) {
**window.location.href = "Browse/" + date.format('dd-mm-yyyy';**
}
},
events: function (start, end, callback) {
// do some asynchronous ajax
contentType: "application/json; charset=utf-8",
$.getJSON("/WhatsOn/CalendarData/",
function (result) {
if (result != null) {
for (i in result) {
var calEvent = result[i];
calEvent.start = new Date(parseInt(calEvent.start.replace("/Date(", "").replace(")/", ""), 10));
calEvent.end = new Date(parseInt(calEvent.end.replace("/Date(", "").replace(")/", ""), 10));
calEvent.url = "Details/" + calEvent.ID;
}
}
var calevents = result;
// then, pass the CalEvent array to the callback
callback(calevents);
});
}
});
});
</script>
Obviuosly this isn’t working, the date being returned is in the format
Browse/Mon Aug 01 2011 00:00:00 GMT+0100 (GMT Daylight Time)
I’ve looked in the fullcalendar.js and I can’t find where this date is fomated.
Any help would be great!
Thanks!
Try like this: