Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Open event that emit when the popup is shown #137

Open
georges49 opened this issue Apr 9, 2019 · 3 comments
Open

Open event that emit when the popup is shown #137

georges49 opened this issue Apr 9, 2019 · 3 comments

Comments

@georges49
Copy link

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.

@fuoridallarete
Copy link

Did you find a way?

@darrenklein
Copy link

darrenklein commented Dec 14, 2020

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
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants