Skip to content
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