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