Skip to content

Update README.md #60

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Otherwise, the `mixins` way also works.
@keydown.up="up"
@keydown.enter="hit"
@keydown.esc="reset"
@blur="reset"
@input="update"/>

<!-- the list -->
Expand Down Expand Up @@ -97,7 +96,25 @@ export default {
// data = ...
return data
}
}

// Check that the click event location was outside of $el. I.e this template
leave (e) {
// This checks to make sure that the click was on something other than this template it, input or ul.
if (!this.$el.contains(e.target)) {
this.reset;
}
},
},

mounted: function () {
// Add the event listener to the document on mount
document.addEventListener('click', this.leave, false);
},

destroyed: function () {
// Remove the event listener before being distroyed to prevent bubble up
document.removeEventListener('click', this.leave, false);
},
}
</script>

Expand Down