Popover now also removes its eventlistener on close

This commit is contained in:
2019-10-22 23:08:03 +02:00
parent c454d9c9e0
commit 4528b240e1

View File

@@ -12,16 +12,31 @@
import Movie from './Movie.vue';
export default {
props: ['id', 'type'],
props: {
id: {
type: Number,
required: true
},
type: {
type: String,
required: true
}
},
components: { Movie },
created(){
let that = this
window.addEventListener('keyup', function(e){
if (e.keyCode == 27) {
that.$popup.close()
methods: {
checkEventForEscapeKey(event) {
if (event.keyCode == 27) {
this.$popup.close()
}
})
}
},
created(){
window.addEventListener('keyup', this.checkEventForEscapeKey)
},
beforeDestroy() {
window.removeEventListener('keyup', this.checkEventForEscapeKey)
}
}
</script>