Here's some javascript:
linkElem.click(function () {
var data = linkElem.data();
alert(''+data.mls + ' ' + data.id);
});
It works.
linkElem
is a local variable that I create in a loop inside a function. I assign some data to it with jQuery's .data()
. If I did not call .click()
, linkElem
would be reassigned during the loop and then recycled after the function returns. However, I have created an anonymous function which references linkElem
. So I am no longer sure what is going on.
My guess is that all of the anonymous functions and linkElem
s created during the loop are given UIDs of some kind and moved to persistent/global scope. Is this correct? Gratuitous detail would be much appreciated.