Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Date Picker on focus

Aletiger premium asked 7 years ago


Hi,

I just started using the Date Picker MDPro module (v. 4.4.1).
I noticed this problem: the modal popup shows up everytime the browser's tab gains the focus.

Ex. I click on another browser's tab or I iconize the browser's window. When I click back to the tab with datapicker, the modal shows up.

I noticed this behaviour also in your example: https://mdbootstrap.com/javascript/date-picker/

I need the modal to show up only when the user clicks on the form.

Best regards,
Alessandro


Aletiger premium commented 7 years ago

I investigated the problem. I think that is related to the fact that the input field has the focus and the calendar is always opened on the focus event. The date picker has the focus, so when you are back from another tab, the calendar will show up again. I'm not able to get the focus lost when I close the calendar the first time. Any idea?

Mirosław Stasiak free answered 7 years ago


Hi, Try this code
<script>
 $('.datepicker').pickadate();
 var $input = $('.datepicker').pickadate();
 var picker = $input.pickadate('picker');
   picker.on({
     close: function() {
       console.log('Closed now'); 
       $(document.activeElement).blur();
     },
   })
</script>
Now everything should work properly. Regards,

Aletiger premium commented 7 years ago

Dear Miroslaw, thanks a lot for your support. Your solution works fine. Best regards, Alessandro


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: Premium
  • Premium support: Yes
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags