Hi there, I'm inserting events into a mysql table using jQuery's Dialog UI widget, and I'm stuck with only one insertion per dayClick. To insert another event I have to refresh the page :/
Here's the code `dayClick: function(date, allDay, jsEvent, view) {
if (view.name=='month') {
$('#calendar').fullCalendar( 'changeView', 'agendaWeek' );
}
else {
// change the day's background color just for fun
$(this).css('background-color', 'red');
$("#dialog-form #pdal").val($.fullCalendar.formatDate( date, 'yyyy-MM-dd' ));
$("#dialog-form #pdalle").val($.fullCalendar.formatDate( date, 'HH:mm' )).attr("value",$.fullCalendar.formatDate( date, 'HH:mm' ));
$("#dialog-form #palle option[value='"+$.fullCalendar.formatDate( date, 'HH:mm' )+"']").attr("selected","selected");
$('#dialog-form #risorsa').val("0");
$('#dialog-form #CheckboxGroup1_0').attr("checked","checked").val($.fullCalendar.formatDate( date, 'yyyy-MM-dd' ));
$('#dialog-form #CheckboxGroup1_0').after($.fullCalendar.formatDate( date, 'yyyy-MM-dd' ));
$('#dialog-form').dialog('open');
}//else
}`
I know it's a bit crude, and it would be better to close the dialog on succesful insertion in this code block, but it works, for now, more or less.
the actual insertion is called via the Dialog button. Here's the code:
`$("#dialog-form").dialog({ autoOpen: false, height: 900, width: 860, modal: true, beforeclose: $("#dialog-form form").clearForm(), buttons: { 'Inserisci lezione': function() {
allFields.removeClass('ui-state-error');
$.post("smfn_set_event.php", { idaula:$("#dialog-form #idaula").val(), dal:$("#dialog-form #pdal").val(), dalle:$("#dialog-form #pdalle").val(), alle:$("#dialog-form #palle").val(), idutente:$("#dialog-form #idutente").val(), motivo:$("#dialog-form #motivo").val(), nota:$("#dialog-form #nota").val() },
function(datainsert){ alert("Msg returned: " + datainsert); }); $('#calendar').fullCalendar('refetchEvents'); $('#calendar').fullCalendar( 'render' ); $(this).dialog('destroy'); $(this).dialog('close');
},`
The clearForm and destroy bits are an attempt to not have the form fileds filled with the last entered values. Unfortunately now the Dialog doesn't get opened any more.
Is there something evidently wrong in this code?
Thanks.