bootstrap-4: Failure if input field pre-populated
If there is any data existing in the input field, the script fails. Also it alters the date field’s time from ‘23:46:00’ to ‘11:48 AM’ which won’t validate with my CMS (it needs 24h time)
- Firefox 57.0.2 reports
too much recursionthenTypeError: config is undefined - Chrome reports
Uncaught RangeError: Maximum call stack size exceededthenjQuery.Deferred exception: Invalid regular expression: /(^|\.)datetimepicker(\.|$)/: Stack overflow SyntaxError: Invalid regular expression: /(^|\.)datetimepicker(\.|$)/: Stack overflow - MS Edge reports
Out of stack spacethenUnable to get property '_options' of undefined or null referenceJSFiddle here: https://jsfiddle.net/elyptic/ypc4dhv0/
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 1
- Comments: 20 (4 by maintainers)
Commits related to this issue
- Add files via upload Demo file for fix for https://github.com/tempusdominus/bootstrap-4/issues/39 — committed to alexroosenstein/bootstrap-4 by alexroosenstein 6 years ago
@mftruso maybe like this?
https://jsfiddle.net/28c7gq73/32/
I managed to find what was causing it, these lines: https://github.com/tempusdominus/bootstrap-4/blob/master/build/js/tempusdominus-bootstrap-4.js#L387-L390
I moved those to after https://github.com/tempusdominus/bootstrap-4/blob/master/build/js/tempusdominus-bootstrap-4.js#L2689
Which results in the following: https://jsfiddle.net/382mxtas/ (I also added the data-date-format=“MM/DD/YYYY HH:mm:ss” attribute, that fixes the time issue reported in the original issue)
I didn’t create a pull request as I didn’t test it properly, I don’t know what further effects this has.
It happens only if you use the
datetimepicker-inputclass. If you change it todatetimepicker(or something else) there’s no error, but the datetimepicker doesn’t close when it loose focus.I don’t have a solution, but this might help.
https://jsfiddle.net/03ou5g17/
I got recursion error due to
datetimepicker-input. Fixed it by removing that class as suggest by @azeos . Is there another “fix”?I’m using BS4 and latest tempus dominus bootstrap datetime picker as of today.
This is not an issue. This works like a charm for me. Even if date field is pre-populated or empty. Use the following HTML structure. It will work properly.
Make sure you add
dateclass to your input group div anddata-target-input="nearest". Also adddata-target="#printDatePicker"to yourinputandinput-group-appenddiv.Here is a new fiddle that works, as long as you parse the date as a moment() manually and provide an output format as well. I think the parsing into a moment() should be automatic as well as following the input format (i.e. HH:mm:ss, not HH:mm A). Forcing the output format works though. https://jsfiddle.net/elyptic/28c7gq73/
@tostercx looks like its working. I used @azeos’s workaround by renaming the
datetimepicker-inputclass.Got it to work like this: https://jsfiddle.net/28c7gq73/4/
Separately initializing with the format set and then setting the date back seems to work for now.