background

In a project I am currently working on, I need to add a column of order data in the modal box, and the date of the order must be added when the order data is added. The date plug-in is used to add the order date, so I choose the bootstrap-datetimepicker plug-in with the date format. I have also used this plug-in before. It also felt very good, but this time in the process of doing the project encountered such a problem: When input on it in the modal dialog box, choose to date, but the date when the choice, some no display, I think you can slide the whole modal window, so that the plugin starts to slide in date format, but did not think of, the modal dialog on slippery, but stay on the following date format plugin has been fixed, the diagram below:

Search for solutions

When confronted with a problem, I started various searches. Most of them were Datepicker solutions on Google, but none of the answers worked. First, I searched on Stack Overflow, which gave me the answer:

I used the method he gave, but it did not solve my problem. I searched GitHub again, and the result was the same problem, as shown in the screenshot below:

Since all can’t solve, oneself also have no way, that can only find another way.

The solution

PickerPosition: dateTimePicker: pickerPosition: dateTimePicker: pickerPosition: pickerPosition The reason for this is that the plugin is displayed below the input field, so I can’t display the date, and the slide up is to display the date below the input field, so why don’t I start by displaying the date plugin above the input field, so I set this value to ‘top-right’, The results really make a difference. As shown below:

The specific code is as follows:

<script>
    $('#datetimepicker').datetimepicker({
        Here are the other configuration items. pickerPosition:'top-right'}); </script>Copy the code

Conclusion:

  1. Will certainly encounter all sorts of problems in programming, and encounter difficulties, usually search, but after using the search method can’t solve the problem, then need to calm down and think about it, or put this problem aside, in the process of doing other things could be all of a sudden inspiration to open, go back to the question, can be solved.
  2. Don’t get stuck in a dead end or you’ll have a very inefficient day.