vue-datetime icon indicating copy to clipboard operation
vue-datetime copied to clipboard

Open event that emit when the popup is shown

Open georges49 opened this issue 6 years ago • 3 comments

In the documentation, I see that there is a close event but there is no open event.

What I am trying to do is the following: I want to set the max datetime to the current datetime. The component is rendered in the screen and there are multiple inputs to fill so when the user reaches the datetime picker, the max date time is 2 or 3 minutes behind the current date time.

For this reason I want to set it when the popup is opened.

georges49 avatar Apr 09 '19 15:04 georges49

Did you find a way?

fuoridallarete avatar May 07 '20 15:05 fuoridallarete

This would be a very helpful event.

Looks like PR #175 would address this, but the owner of this repo requested that the author update the README and add tests, but the author of the PR hasn't followed up.

darrenklein avatar Dec 14 '20 03:12 darrenklein

Here's the workaround I've been using...

  mounted() {
    const datetimeElement = document.getElementsByClassName("vdatetime")[0];

    datetimeElement.addEventListener("click", (event) => {
      if (event.target.className === "vdatetime datetime") {
        this.handleOpen();
      }
    });
  },
  methods {
    handleOpen() {
      // do something...
    }
  }

You need the event.target.className === "vdatetime datetime" conditional because, once the picker is open, clicks on the modal backdrop will be registered by this event handler.

darrenklein avatar Feb 25 '21 01:02 darrenklein