+3  A: 

First thing that strikes my eye: IDs should be unique. Change your IDs for A tags into classes, and see if that clears it up.

D_N
yes i tried that (in a git branch) but It did not solve my problem, so i reverted
Eugen
Try it again - you cannot share "id" values between multiple elements. Every "id" must be perfectly unique on any page.
Pointy
Here you go http://jsfiddle.net/NMpU5/1/ The bug is still there
Eugen
A: 

When you use jQuery selectors like '#something', the library uses "document.getElementById()" to find the elements. You cannot expect things to work if you're using the same "id" value for multiple elements; in fact you'll get results exactly as you describe. The fact that you're using "find()" to look for elements by shared "id" does not matter.

That problem aside, you need to be using "name" attributes for your form input fields anyway.

Pointy
Okay I changed all ids to classes but the bug is still there http://jsfiddle.net/NMpU5/1/Thanks for the remark about the form fields
Eugen
wow you're fast :-) I'm looking at it now.
Pointy
A: 

you don't have to change de IDs to classes. you just need unique ids to each element, so you can get the right one.

j.
hmm okay i think that would work somehow. But anyway, the jQuery selectors should find find the right form, because I nested it that way, that find() should find the right form
Eugen
+3  A: 

It looks to me as if many of the variables in your event handler functions (notably, "post" and "relatedDiscussion") are not declared with "var" in each function. I've tried to figure out exactly what that might do, but I got confused. Nevertheless, when you do not declare your local variables, they're global variables. That means that each function that sets "post" equal to some new value is changing the value used by "post" in all the other functions that may be active.

Change it to

 var post = $(this);

etc.

Pointy
Oh thank you, that's been the bug! That's what I get for not remebering javascript basics! I actually wondered that firebug showed me that the (not so) local variables had already a value before assigning s.th. to them. But I assumed that it's been just an inconsistency in firebug. you can see the updated version here http://jsfiddle.net/NMpU5/4/Again thanks ;)
Eugen
+1  A: 

You should use jQuery's live events to bind to the form instead of binding a click to each button after creation.

I posted an update to your script

I basically pulled out the form click functions and converted them to live functions

$(".cancel").live("click", function(){
    $(this).closest(".post-comment-form").slideUp('',function(){ $(this).remove(); });
});
$(".preview").live("click", function(){
    // Hier muss mit Ajax und der Datenbank gespielt
    // werden um ein preview erstellen zu können
});
$(".submit").live("click", function(){
    // Hier muss mit Ajax und der Datenbank gespielt
    // werden um den Post abschicken zu können
});

I didn't use your post.triggerHandler("destroyForm"); function because frankly I've never used it before and I couldn't get it to work LOL.

fudgey
You might also want to look into changing `.parents()` into `.closest()`. The code gets very confusing when I'm trying to figure out where in the post and how far into the replies you are. I'd say remove your `.bind()` functions entirely and replace them with `.live()`
fudgey
thanks for the remarks but the probelm is already solved. The `destroyForm` is a custom event I created with `bind()`. I'll look into `closest()`.
Eugen