this is a simpler simple. for my project i have to use nested switch in a function. and inside of the switch there are many functions and events. the function has to be fired at "selectable stop event" for capture how many elements are selected.
my problem is how to destory the previous function ( or maybe a obj? ) when the function is re-fired again? what i do now is "unbind" the "events" within the function when its finished. ( not shown on the example above, coz if i do so we won't be able to see how many times the functions is fired ) but i think by doing that the old function is still exist in the memory?
from the sample above after we select the items and clilck the edit title btn ( or any other edit btn ). it shows a msg box and after we click yes it fires a alert to let us now the edit btn click event is fired and hide the msg box. now when we do this one more time, we will have the alert 2 times. as we do it more and more again, the alerts get more as well. which mean the previous functions still exist in the memory.
i don't know how i can detory them, i've try to set the function to null, but functions inside the function still exist.