I am trying to the following:
- user clicks on a specific date
- fancybox opens with data entry options
- capture the date on which the calendar was clicked
- grab that date and inject it into the
valueof a textinput
This is my code:
$("a#inline").fancybox();
$('#calendar').fullCalendar(
{
dayClick: function (date)
{
$('a#inline').click();
$('.datepicker').val(date);
}
});
HTML
<a href="#data_entry" id="inline">Add Event</a>
<div style="display:none">
<div id="data_entry">
<form action="events/events_save" method="post" name="events_form" id="events_form">
<input type="text" name="date" value="<?php date('m/d/Y'); ?>" class="datepicker">
</form>
</div>
</div>
I am running into the following issues:
-
when clicking on a date on the calendar the fancybox pops up and I get
Mon Apr 25 2011 00:00:00 GMT-0400 (EDT)==> I need this to be mm/dd/yy like04/25/11 -
if right after that I close the fancybox and click on the anchor tag
"Add Event", the fancybox opens but the date is populated withMon Apr 25 2011 00:00:00 GMT-0400 (EDT)==> it should actually contain today’s date because of the PHP string I put in thevaluefield (this is fixed only if I refresh)
Anyone have suggestions on how to solve either issue?
Thanks a ton.
To format dates, run the date through fullcalendar’s formatDate method. Try: