[jQuery] javascript loaded via ajax

2010-01-13 Thread nihal
hi i have a div whose content is loaded via ajax..that content contains html+javascript the javascript contains a function called test() when the content is loaded this function is added to the dom...now when i remove the div using remove(); i am still able to run the function test() as its still

Re: [jQuery] javascript loaded via ajax

2010-01-13 Thread Nathan Klatt
On Wed, Jan 13, 2010 at 1:53 PM, nihal nihal.c...@gmail.com wrote: is there anyway to remove the newly added function from the dom? Wrap the code you want to be removeable in its own script element, give it an id, then remove it just like any other element. As has been discussed today, removing

Re: [jQuery] javascript loaded via ajax

2010-01-13 Thread Michael Geary
Removing a script element just removes the script's *source code* from the DOM. It doesn't undo any actions that the script has already performed, such as defining functions or variables or creating other DOM elements. It doesn't change their availability for garbage collection at all. In your

Re: [jQuery] javascript loaded via ajax

2010-01-13 Thread Nathan Klatt
On Wed, Jan 13, 2010 at 6:45 PM, Michael Geary m...@mg.to wrote: In your example, the hello function will never be garbage collected, because the window object has a property named 'hello' that holds a reference to the function. Thanks for the correction. Nathan