Skip to content

Commit

Permalink
Set timepicker field value when clicking "done" if not changing time …
Browse files Browse the repository at this point in the history
…(use default 12:00). Fixes CMB2#1027
  • Loading branch information
jtsternberg committed Sep 18, 2017
1 parent ebf68b4 commit 0b010a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion js/cmb2.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,11 @@ window.CMB2 = window.CMB2 || {};

options.onClose = function( dateText, inst ) {
// Remove the class when we're done with it (and hide to remove FOUC).
$id( 'ui-datepicker-div' ).removeClass( 'cmb2-element' ).hide();
var $picker = $id( 'ui-datepicker-div' ).removeClass( 'cmb2-element' ).hide();
if ( 'timepicker' === method && ! $( inst.input ).val() ) {
// Set the timepicker field value if it's empty.
inst.input.val( $picker.find( '.ui_tpicker_time' ).text() );
}

// Let's be sure to call onClose if it was added
if ( 'function' === typeof existing.onClose ) {
Expand Down
Loading

0 comments on commit 0b010a0

Please sign in to comment.