Skip to content

Does not works in Bootstrap modal #16

@rez0n

Description

@rez0n

Hi @monim67
Thanks for this module!
I faced with issue that it does not works in the Bootstrap modal as initialization JS waiting for DOMContentLoaded event, but modal does not fires this event.

django-flatpickr.js:53

  document.addEventListener('DOMContentLoaded', function (event) {
    findAndProcessFlatpickrInputs(document);
    document.addEventListener('DOMNodeInserted', function (event) {
      setTimeout(() => {
        if (event.target.querySelectorAll) findAndProcessFlatpickrInputs(event.target);
      });
    });
  });

Modifying django-flatpickr.js:53 this way - everything becamoe work correctly, I created another copy of this file to use in modals, would be cool to find solution for both cases (DOMContentLoaded and shown.bs.modal) but I have no ideas right now.

document.addEventListener('shown.bs.modal', function (event) {
    findAndProcessFlatpickrInputs(document);
    document.addEventListener('DOMNodeInserted', function (event) {
      setTimeout(() => {
        if (event.target.querySelectorAll) findAndProcessFlatpickrInputs(event.target);
      });
    });
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions