jQuery datepicker only works once and is not shown the second time

后端 未结 10 1337
庸人自扰
庸人自扰 2021-01-02 06:32

ASP.NET MVC3 / jQuery 1.9.1 / jQuery UI 1.10.2

I\'ve got a page on which I open a modal dialog after clicking on an Ajax.ActionLink. Inside this dialog

10条回答
  •  庸人自扰
    2021-01-02 06:46

    I wanted to re-inititalise the date picker after modal close as the values selected during the first trial for setting of the dates were still there. So i dont know why but the following code doesnt work for me.

    $(selector).datepicker("refresh") 
    

    The above line mentioned in the documentation didnt help!.

    Following is something which i tried, i.e to destroy and reinititalise the date picker objects.

    $('#addPromoModal').on('hide.bs.modal', function(event) {
    $("#startDate").datepicker("destroy");
    $("endDate").datepicker("destroy");
    initialiseDataPicker(); }
    

    Here is my initialise function :

    function initialiseDataPicker(){
    
     $( "#startDate" ).datepicker({
        defaultDate: "+1w",
        showWeek: true,
        firstDay: 1,
        changeMonth: true,
      //  numberOfMonths: 3,
       onClose: function( selectedDate ) {
         $( "#endDate" ).datepicker( "option", "minDate", selectedDate );
       }
     });
     $( "#endDate" ).datepicker({
         defaultDate: "+1w",
        showWeek: true,
        firstDay: 1,
        changeMonth: true,
      //  numberOfMonths: 3,
       onClose: function( selectedDate ) {
         $( "#startDate" ).datepicker( "option", "maxDate", selectedDate );
       }
     });
     }
    

    Hope That helps! RA

提交回复
热议问题