I have a problem
open: function($type) {
//Some code
document.getElementById($type).addEventListener("click", l.close($type), false);
},
close: function($type) {
//There is some code too
document.getElementById($type).removeEventListener("click", l.close($type), false);
//^ Recursion & Uncaught RangeError: Maximum call stack size exceeded
}
What I'm doing wrong? Without this click event listener everything is working well. And what is the third parameter doing (true|false)? Thank you.
You are calling the close
function in the addEventListener
and removeEventListener
when you are trying to pass is as an argument (causing an infinite loop). Instead you should simply pass the reference to the function as follows:
document.getElementById($type).addEventListener("click", l.close, false);
And:
document.getElementById($type).removeEventListener("click", l.close, false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With