wbraganca yii2 dynamic form date picker issue?

后端 未结 1 1318
半阙折子戏
半阙折子戏 2020-12-18 14:27

I am using wbraganca dynamic form. In my form one field need date picker,so i use jui date picker like below

field($model, \"[{$i}]DOB\")-&g         


        
相关标签:
1条回答
  • 2020-12-18 15:08

    Use afterDelete and reinitialize datepicker :

    $this->registerJs(' 
    $(function () {
        $(".dynamicform_wrapper").on("afterInsert", function(e, item) {
            $( ".dob" ).each(function() {
               $( this ).datepicker({
                  dateFormat : "dd/mm/yy",
                  yearRange : "1925:+0",
                  maxDate : "-1D",
                  changeMonth: true,
                  changeYear: true
               });
          });          
        });
    });
    $(function () {
        $(".dynamicform_wrapper").on("afterDelete", function(e, item) {
            $( ".dob" ).each(function() {
               $( this ).removeClass("hasDatepicker").datepicker({
                  dateFormat : "dd/mm/yy",
                  yearRange : "1925:+0",
                  maxDate : "-1D",
                  changeMonth: true,
                  changeYear: true
               });
          });          
        });
    });
    ');
    

    You need to remove class hasDatepicker to reinitialize datepicker.

    0 讨论(0)
提交回复
热议问题