I’m having trouble with a piece of script that removes an object X amount of time after it has gotten the class ‘hidden’
selector = getselector($(this).parent().parent());
console.log("Clicked Cancel");
$(this).parent().parent().addClass('hidden');
setTimeout(function() {
$(selector).remove();
}, 400);
I edited some piece of script from here to make function getselector since $(this) doesn’t work within a setTimeout.
now this piece of code works, as long as you don’t run it too quickly again.
problem seems to be that variable selector gets messed up when a another node gets deleted within the timespan (currently 400ms)
and I can’t think of an easy way around it. 🙁
The answer is simple: Don’t make
selectorglobal, i.e. usevar. Oh, and simply store the element instead of trying to build a selector: