Please see demo here: http://jsfiddle.net/mA6qm/1/ (expand console)
Why aren’t events being sent or received between two object yet the same code works fine when it’s placed in the global scope?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The issue is that the object you’re binding the event to is not the same object you’re triggering it on. In the
setTimeoutcallback,thiswill not refer tocalling_objecteven though you definedfinishedas a method on that object. Instead it will refer to the window. Similarly, when you bound the event the event was bound onlistening_object. You need to make sure you’re using the same object for both.