jQuery UI datepicker opens automatically within dialog

后端 未结 12 1705
面向向阳花
面向向阳花 2020-12-16 10:14

I have a datepicker which is used within the jQuery dialog object. The source of the dialog\'s content is loaded using .load(). Within the dialog I created a sc

12条回答
  •  情书的邮戳
    2020-12-16 10:51

    I was having a similar problem. I have a jquery datepicker inside a jquery ui dialog. The date picker was opening automatically in IE when I opened the dialog. It was not doing that in Firefox or Chrome... I fixed the problem by disabling the datepicker upon creation in the $(document).ready like so:

    $('.ConfirmMove #from').datepicker({
      duration: ''
    }).datepicker('disable');
    

    Then when I was opening the dialog containing this datepicker I enabled it in the open event handler of the dialog:

    $(".ConfirmMove").dialog({
      close: function() { 
         $('.ConfirmMove #from').datepicker('disable'); 
      },
      open: function() {
         $('.ConfirmMove #from').datepicker('enable');
      }
    });
    

    You also have to remember to disable it back when you close the dialog.

    This way you also don't destroy and recreate the datepicker each time you open and close the dialog.

提交回复
热议问题