开发者

Fullcalendar dayClick code fires only once: what am I doing wrong?

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 t开发者_如何转开发he 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.


$(this).dialog('destroy') 
  • Remove the dialog functionality completely. This will return the element back to its pre-init state. (http://jqueryui.com/demos/dialog/)

So, when you try

$('#dialog-form').dialog('open'); 

after destroy - nothing happens. You should only close dialog after inserting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜