Skip to content
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

Hours can go negative when defaultTime is set to false #194

Open
carpeliam opened this issue Dec 30, 2013 · 4 comments
Open

Hours can go negative when defaultTime is set to false #194

carpeliam opened this issue Dec 30, 2013 · 4 comments

Comments

@carpeliam
Copy link

If defaultTime is set to false, and the user clicks the down arrow for either hours or minutes (or seconds if they're enabled), then the hour will be set to -1. (If seconds are enabled, minutes are properly decremented to 59.) This only happens the first time the timepicker popup is rendered.

I created a jsfiddle example of this here.

@carpeliam
Copy link
Author

I did some quick debugging- if your cursor is focused on the input element and you click the decrementHour link, this triggers a blur event on the input, which causes the clear() method to get called, which sets hour to an empty string. Maybe clear() shouldn't be called if the new focus is within the $widget... I dunno, I'll have to take a closer look later on.

@bryanweaver
Copy link

I just wanted to post an update, since I just ran into this problem:
I tested to see if the negative value could be saved into the DB, and it turned out to save null, so no problem there (...still, the UI shows '-1', which isn't right).
For me (without forking), the best solution is to pass in an empty string as the defaultTime. This will keep the unedited controls showing blank, and when they click in the element to edit, it will show as '1:00 AM'. This may not be ideal, but at least the user will not be able to select a negative time value.
I hope this helps someone!

@Braunson
Copy link

+1 Thanks @bryanweaver for the temporary solution however I still have the negative issue when they click down.

@tungnt25
Copy link

tungnt25 commented Jun 17, 2016

Solution: I think we should set the defaultTime once again, the timepicker has a function name setDefaultTime after set it we never get the negative issue like this
$('#birthTime').timepicker('setDefaultTime',"11:00 AM");

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

4 participants