JQuery datePicker date reset

前端 未结 6 1254
耶瑟儿~
耶瑟儿~ 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 21:13

    Here is the scoop

    We can use default done button to bind a custom clear function.

    $("#date_picker").datepicker({minDate:myDate,dateFormat: 'yy-mm-dd',showButtonPanel:true,closeText:'Clear',
        beforeShow: function( input ) {
            setTimeout(function() {
            var clearButton = $(input )
                .datepicker( "widget" )
                .find( ".ui-datepicker-close" );
            clearButton.unbind("click").bind("click",function(){$.datepicker._clearDate( input );});
            }, 1 );
        }
    }); 
    

    Works like a charm. Cheers :);)

    credits: Sébastien Renauld and BehranG BinA

提交回复
热议问题