Issue 68: Dynamically Adding Event Start Date
Status:  Done
Owner: ----
Closed:  Jul 2009
Reported by jetmirh...@gmail.com, Jul 29, 2009
I am trying to use the dialog function of jQuery ui to be able to add an
event on the fullcalendar. How do you pass the start date dynamically to
the addEvent call after you submit the dialog window?

My code is below. Any help would be appreciated!

<script type='text/javascript'>

	$(document).ready(function() {
	var myday;
		$('#calendar').fullCalendar({
			draggable: true,
			events: "example.php", //"json_events.php",
			eventDrop: function(event, delta) {
				alert(event.title + ' was moved ' + delta + ' days\n' +
					'(should probably update your database)');
			},
			dayClick : function(evDay) {
			$('#dialog').dialog('open');
			var date,
				month,
				year;
				date = evDay.getDate();
				month = evDay.getMonth() + 1;
				year = evDay.getFullYear();
			myday = year + "-" + month + "-" + date
			$(function() {
	
		var menu = $("#menu"),
			size = $("#size"),
			allFields = $([]).add(menu).add(size),
			tips = $("#validateTips");

		function updateTips(t) {
			tips.text(t).effect("highlight",{},1500);
		}
			
		$("#dialog").dialog({
			bgiframe: true,
			autoOpen: false,
			height: 320,
			modal: true,
			buttons: {
				'Order': function() {
					var bValid = true;
					var mydayin = myday;
					allFields.removeClass('ui-state-error');
					$('#calendar').fullCalendar( 'addEvent', {
						title: 'Meal Ordered',
						start: document.print($mydayin)//'2009-07-18'
						});
					
						$(this).dialog('close');
				},
				Cancel: function() {
					$(this).dialog('close');
				}
			},
			close: function() {
				allFields.val('').removeClass('ui-state-error');
			}
		});

	});
       		 },
			eventClick : function(event, $event) {
			$('#dialog').dialog('open');
       		 },
			loading: function(bool) {
				if (bool) $('#loading').show();
				else $('#loading').hide();
			}
		});
	});

</script>
Jul 31, 2009
Project Member #1 adamrs...@gmail.com
the line...

start: document.print($mydayin)

...doesn't make much sense, might need to brush up on javascript basics. the start date 
needs to be the *value* of the date, not a print statement. you get the value of the 
date by querying your text input (or whatever), which doesn't seem to be defined here 
yet
Status: Done