I’m listening to a custom event:
JavaScript
x
13
13
1
evt = new CustomEvent("fileThisEmail", {
2
detail: {
3
name: name,
4
email: email,
5
content: content
6
}
7
});
8
9
window.dispatchEvent(evt);
10
11
12
window.addEventListener("fileThisEmail", this.handleFileEmail);
13
I need to remove the listener. I’ve tried:
JavaScript
1
3
1
window.removeEventListener("fileThisEmail", this.handleFileEmail);
2
window.removeEventListener("fileThisEmail");
3
but neither work. What am I doing wrong?
Advertisement
Answer
The third argument to removeEventListener is mandatory. try this:
JavaScript
1
2
1
window.removeEventListener("fileThisEmail", this.handleFileEmail, false);
2