Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Remove eventlistener for anonymous functions with a reference
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
TheRave  
View profile  
 More options Oct 16 2012, 3:38 pm
Newsgroups: mozilla.dev.extensions
From: TheRave <micha.post...@arcor.de>
Date: Tue, 16 Oct 2012 12:38:27 -0700 (PDT)
Local: Tues, Oct 16 2012 3:38 pm
Subject: Remove eventlistener for anonymous functions with a reference
Hello,

according my tests for removing an eventlistener definied for a anonymous function i found a solution, but i doesn't know why this works.

var myExtension = {
  init: ....

},

onPageLoad: function(aEvent) {

var test = "test";

doc.addEventListener("textAreaEvent", afunc = function(evt){onChangeTextArea(evt, data);}, false);

....

},

onPageUnload: function(aEvent) {
                //alert(test); <---- of course unknown

                alert(afunc); <----Why is afunc known here?

                aEvent.originalTarget.removeEventListener("textAreaEvent", afunc, false);

Can somebody give me an explanation why this workarround works and afunc is well known for onPageUnload? There is no global var afunc defined it was only done in addeventlistener.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Godmar Back  
View profile  
 More options Oct 16 2012, 3:43 pm
Newsgroups: mozilla.dev.extensions
From: Godmar Back <god...@gmail.com>
Date: Tue, 16 Oct 2012 15:43:00 -0400
Subject: Re: Remove eventlistener for anonymous functions with a reference

Unless you have a 'var afunc' in a smaller scope, this sets 'afunc' in the
global scope.
So no surprise here.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
TheRave  
View profile  
 More options Oct 16 2012, 3:52 pm
Newsgroups: mozilla.dev.extensions
From: TheRave <micha.post...@arcor.de>
Date: Tue, 16 Oct 2012 12:52:20 -0700 (PDT)
Local: Tues, Oct 16 2012 3:52 pm
Subject: Re: Remove eventlistener for anonymous functions with a reference
Yes. Now i can remember that vars defined without "var" are in global scope. That's it! Thank you.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »