bootstrap-timepicker
bootstrap-timepicker copied to clipboard
not change value in input box
not change value in input box when i change in dropdown value without use button(up / down) only use manually
I have the same problem too
I think I found the issue, I'm just not sure how to fix it. The problem is if you used the bootstrap-datepicker example for bootstrap-timepicker, it almost works but it fails to update the input box. Comparing code, timepicker uses something like this.$element.val(x) to set the underlying input box value whereas datepicker uses something like this.$element.find('input').val(x). I have experimented with updating the code to include the find on the set and this seems to work, but updating the get equivalent does not seem to work as intended.
Right now my work around is to not use the datepicker sample method.
I found the reason which cause the problem is keyCode always return 229 in some input method. According to W3C:
If an Input Method Editor is processing key input and the event is keydown, return 229.
and I found below in source code:
widgetKeyup: function(e) {
if (
e.keyCode === 65 ||
e.keyCode === 77 ||
e.keyCode === 80 ||
e.keyCode === 46 ||
e.keyCode === 8 ||
(e.keyCode >= 46 && e.keyCode <= 57) ||
(e.keyCode >= 96 && e.keyCode <= 105)
) {
this.updateFromWidgetInputs();
}
},
so if you use some input method like chinese or japanese, the keycode return 229 won't trigger the updateFromWidgetInputs method, and of course value in input box won't change.
My solution is quite simple, just add the keyCode 229 into the list, and it did solve the problem.