JQuery datePicker date reset

前端 未结 6 1226
耶瑟儿~
耶瑟儿~ 2020-12-14 20:37

I would like to add a \"Reset\" control to the datepicker at the bottom of the calendar - where the \"close\" control goes. This would enable the user to reset the input tie

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-14 20:55

    Here is working solution, just call cleanDatepicker() before any call to datepicker.

    function cleanDatepicker() {
       var old_fn = $.datepicker._updateDatepicker;
    
       $.datepicker._updateDatepicker = function(inst) {
          old_fn.call(this, inst);
    
          var buttonPane = $(this).datepicker("widget").find(".ui-datepicker-buttonpane");
    
          $("").appendTo(buttonPane).click(function(ev) {
              $.datepicker._clearDate(inst.input);
          }) ;
       }
    }
    

提交回复
热议问题