Make List Of Several "gm_listvalues", Calling A Function To Remove Themselves
I'm currently working on a Greasemonkey script, that allows to add users to an ignore list which will block their comments from being rendered. I store their userID via 'GM_setValu
Solution 1:
At the end of the loop, currentUser
keeps getting overwritten on each iteration. Inside the click
function, you're referring to currentUser
, which equals the last definition of currentUser
.
To fix it, make use of closures:
function doSomething(currentUser) {
manageBans.append($('<b>'+currentUser+'</b><ahref="javascript:void(null)"><imgsrc="/redaktion/style/delete.png"width="16"height="16"alt="unblock_user"></a></br>').click(function(){
unbanUser(currentUser)
}));
}
for (var i=0; i < banList.length; i++) {
doSomething(banList[i]);
}
Post a Comment for "Make List Of Several "gm_listvalues", Calling A Function To Remove Themselves"