Date Picker on focus


Topic: Date Picker on focus

Aletiger pro 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 pro 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?

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 pro 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
  • User: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No