I am encountering some unexpected behaviors with the events() and unbind() methods.
Here is a short example:
<html>
<head>
<script type="text/javascript" src="brython.js"></script>
<script type="text/javascript" src="brython_stdlib.js"></script>
</head>
<body onload="brython(0)">
<div id="div"> TEST </div>
<script type="text/python">
from browser import document
def listener1(e = None): print("1")
def listener2(e = None): print("2")
document["div"].bind("click", listener1)
document["div"].bind("click", listener2)
print(listener1 in document["div"].events("click")) # print False, should be True
print(listener2 in document["div"].events("click")) # print False, should be True
document["div"].unbind("click", listener2)
</script>
</body></html>
The page print "False" two times in the console, while it should be True (the listener are those bound previously).
Then, if you click on the TEST div, it prints "2" in the console, while it should print "1". listener2 was removed, but actually, it is listener1 that is wrongly removed.
Thank you for providing Brython,
Best regards,
Jiba
Hello,
I am encountering some unexpected behaviors with the events() and unbind() methods. Here is a short example:
The page print "False" two times in the console, while it should be True (the listener are those bound previously).
Then, if you click on the TEST div, it prints "2" in the console, while it should print "1". listener2 was removed, but actually, it is listener1 that is wrongly removed.
Thank you for providing Brython, Best regards, Jiba