jQuery-Timepicker-Addon icon indicating copy to clipboard operation
jQuery-Timepicker-Addon copied to clipboard

Custom clear button disappears when date changed

Open jamesbarsby opened this issue 12 years ago • 4 comments
trafficstars

I have added a custom clear button to my datetimepicker using some code like this:

$( "#mydatefield" ).datetimepicker({
    dateFormat: "dd/mm/yy",
    timeFormat: "h:mmtt",
    beforeShow: function( input ) {
        setTimeout(function() {
            var buttonPane = $( input )
                .datepicker( "widget" )
                .find( ".ui-datepicker-buttonpane" );

            $( "<button>", {
                text: "Clear",
                click: function() {
                    $(input).val('');
                }
            }).addClass('ui-state-default ui-corner-all')
                .appendTo( buttonPane );
        }, 1 );
    }
});

The problem is if I change the date everything is refreshed so my button disappears. I'm guessing this is because the button is created via 'beforeShow'. Is there a way the button could be re-added after the date is changed?

Interestingly changing the time doesn't remove the button.

It's a shame clear buttons aren't a standard feature.

jamesbarsby avatar Dec 18 '12 12:12 jamesbarsby

i also have the same issue.

venkatkoti2007 avatar Jan 29 '15 07:01 venkatkoti2007

+1

aensley avatar Dec 07 '15 18:12 aensley

+1

kgsantosh770 avatar Apr 27 '23 17:04 kgsantosh770

I am not sure this library is still in active development in any way

williamdes avatar Apr 27 '23 17:04 williamdes