Datepicker events issues


Topic: Datepicker events issues

Verlino pro premium priority asked 5 days ago

Hi. I have an issue with datepicker usage.

Expected behavior When clicking on the date in the datepicker modal I should be able to close/confirm/change date. Actual behavior Once I click the date in the modal no events are listened to anymore, I can't close the datepicker, confirm the choice, reselect, etc.

Resources (screenshots, code snippets etc.)

enter code here   <div class="form-outline mb-3 datepicker" data-mdb-datepicker-init data-mdb-input-init>
                    <input type="text" class="form-control" id="Input_date" />
                    <label for="Input_date" class="form-label">Data</label>
                  </div>

... then ...

                    content.querySelectorAll('.datepicker').forEach((date) => {
                        const options = {
                            datepicker: { format: 'dd-mm-yyyy' }
                        }

                        new Datepicker(date, options);
                    });

Kamila Pieńkowska staff answered 2 days ago

You are doing double init. First with a data attribute (data-mdb-datapicker-init) and the second one with new constructor. You need to choose one.


Verlino pro premium priority commented 2 days ago

Thanks for reply. Yes I know, I've tried all combinations to be sure but it still don't work. When I click on a date no events are listened to anymore; I can't clear, confirm, close modal with "X", close modal woth click outside, select other date... This is in version 9.0.0, I never had any problems with previous versions (eg. 8.2.0).


I've fixed your example: https://mdbootstrap.com/snippets/standard/kpienkowska/6419605

If you use it and still have problems, please write how you are doing your imports. I presume you are using UMD imports and copying from documentation examples meant for ES import.


Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 9.0.0
  • Device: PC
  • Browser: Chromium
  • OS: Windows
  • Provided sample code: No
  • Provided link: No