I am doing a crm address of her u-crm.ru (I pointed to a bug to catch) it has tasks, where the date is indicated using the calendar datetimepicker is an excellent calendar, but there is trouble! In my system, all forms for adding tasks, transactions, clients are loaded inside a small html code of a modal window.

The problem is this:

If you add only the task at once, there are no problems, i.e. You add a task , click on the field, the date pops up with a calendar, you poke the desired date and everything is in order.

If, before adding a task, you open some other form, then when you open an add task, a bug arises, when you click on a field, a calendar pops up, you can poke it for a date, the window is minimized, it infuriates customers wildly!

Brothers help can not I can solve this problem = (

Here is a bright gif showing everything

enter image description here

  • one
    Why do you have datetimepickers in the DOM outside the most pop-up form? Do not you think that it is logical to leave the controls where they should be, rather than forcing them to wallow anywhere in the DOM tree? There is a suspicion that because of this, clicking on the calendar does not go into the modal window, but beyond it causing this behavior. - Alex Krass
  • @AlexKrass, it just seems to me that it is because of this, but I just can’t understand exactly what you are saying to do ... I’m already suffering for a week - Alexander Sizintsev

1 answer 1

The problem, as @AlexKrass said, is that the datepicker in the DOM tree is outside the modal window. Therefore, your code, which should work when you click outside the modal window, also works on click on the datepicker .

You have 3 ways to solve this problem:

  1. Move the datepicker body to the right place in the DOM
  2. Before closing the modal window, check whether the datepicker was clicked and if the click was on it, then do not close the modal window.
  3. Start using events
  • solved the problem, just added one parameter that indicates where to add calendar items and that's it. - Alexander Sizintsev