To be short and precise:
I have a link, clicking which a new div is inserted into the list.
Each div contains a link to delete this div.
So, in the middle of working, it looks like this:
<div id="list">
<div id="item"><a href="#" id="remove_item">Remove</a></div>
<div id="item"><a href="#" id="remove_item">Remove</a></div>
</div>
As for the click handler I have
$("#remove_item").live 'click', (e) ->
$(this).parent().remove()
$(this).die() # Unbind
Now, my problem here is in odd behaviour of this handler. If I click on the link of the very last inserted DIV it is being removed properly, but if I click on the very first one – apart from it being removed, it also removes every single one of them, that happen to be standing after it. So clicking the first one, will, basically, remove everything.
And I need to remove only the current one, obviously! 🙂
And I don’t have a clue, why unbinding is not working. I don’t know if it is related to multiple firing or not. 🙁
Can someone help me with this one ?
OK. I don’t know what the problem was, but after I had rearranged some of the HTML layout, the problem was solved. And I still don’t quite understand the reason. Ah well, whatever. Thanks for all of you guys, who tried to help! 🙂