Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mounted() function #31

Open
CryDeTaan opened this issue Dec 28, 2020 · 1 comment
Open

mounted() function #31

CryDeTaan opened this issue Dec 28, 2020 · 1 comment

Comments

@CryDeTaan
Copy link

Would someone please help me understand what is happening with the mounted() function:

I notice popupItem is set to $el but popupItem is never defined.

mounted () {
    // prevent click outside event with popupItem.
    this.popupItem = this.$el
  },
@penance316
Copy link

This is used if the element that is opening (model, select box etc) is already outside of the element with the v-click-outside directive on.

In a situation something like this (ignore any syntax errors its just an example) where the div with the directive is not actually the parent of the element that will be opened/closed.

        <div
          v-click-outside="setOpen = false"
          @click="setOpen = true"
        >
        </div>

        <div
          ref="poppedUpItem"
          :class="{ 'select-hide': !setOpen }"
        >
             Some popup to show here
        </div>

This library has a function that checks if the this.popupItem element is clicked and if so then don't run the click outside logic.

Hope that helps explain it.

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

No branches or pull requests

2 participants