Skip to content

Selecting the input box should not populate with date #391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sgsweb opened this issue Jul 20, 2012 · 4 comments
Closed

Selecting the input box should not populate with date #391

sgsweb opened this issue Jul 20, 2012 · 4 comments

Comments

@sgsweb
Copy link

sgsweb commented Jul 20, 2012

The initial click onto the input box should only popup the datepicker box where the user must make a selection to populate the input box. Currently, this is what happens:

  1. The user clicks on the input box.
  2. The datepicker pops up and a default time is placed in the input box.
  3. The user modifies the date by using the datepicker appropriately.

On line 2, a default time should not be placed in the input box. Instead, the user must select a date/time. If the user closes the datepicker without doing so will render the input box empty.

There should be an additional parameter when creating the datetimepicker that prevents placing date/time onto the input box when the user selects the input box to see the datepicker.

$('element').datetimepicker({noDefaultTime:true})

thanks,
sgs.

@gamov
Copy link

gamov commented Jul 24, 2012

yes, totally agree with that. The worst part of this bug is that if the user 'tabs' through a field with time picker but WITHOUT selecting a time, a default time will be included and user has to take the mouse to clear it...

Actually, it's worse than that: if there already is a date in the field, it will be cleared to put the default date/time as soon as you activate the panel, even though you don't select anything!

@gamov
Copy link

gamov commented Jul 25, 2012

The idea here is to have a disabled text field so user sees the datetime (coming from Rails backend) but can only edit through the picker AND blank value is allowed.
I poked around for hours yesterday to make this work for me. Here is my workaround for my case.
jQuery 1.7.2 / jUI 1.8.22 / datetimepicker 1.0.1.

Datetimepicker (line 584-588):
I commented the following lines

            if (this.inst !== null) {
                var timeDefined = this.timeDefined;
                this._onTimeChange();
                this.timeDefined = timeDefined;
            }

To keep a constant UI (Time pops once you select a time otherwise), add to your configuration:
showTime: false
This configuration is great because you can select a date without a time if you want!

Lastly, to clear the field (since it's disabled), add this to your configuration:

                //HACK -> adding the clear button
                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 );
                }

Hope it helps. I'm a bit shocked that nobody is handling this problem. Maybe I'm doing something wrong but I don't want the user to input ambiguous or incorrect dates... Any comments appreciated.

@trentrichardson
Copy link
Owner

Hey gamov, this use to not happen. At some point an update has changed the functionality... I will look back through the commits

@gamov
Copy link

gamov commented Jul 30, 2012

great, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants