jQuery-Timepicker-Addon
jQuery-Timepicker-Addon copied to clipboard
Custom clear button disappears when date changed
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.
i also have the same issue.
+1
+1
I am not sure this library is still in active development in any way