javascript - Another way to use $this and prev etc to navigate a div -


working on ajax commenting system , far good.

now im putting finishing touches in , come across issue.

if there no comments, there div placed inside comments div says "this blog has no comments"

when posting comment, trying remove div. issue no comments div removed, comment not appended. have put down fact im using .prev() , .closest() , im removing looking for? may wrong...

so here structure if there no comments:

<div class="commentson">     <div class="commentsholder">          <div class='nocomments'>this update has no comments. why not add one?</div>     </div> <form class="addcomment" action="process/addcomment.php" method="post">     <div class="commentbutton">     <input type="text" maxlength="250" name="addpostcomment" class="addpostcomment" placeholder="add comment... (max 60 characters)" />     <input type="submit" id="addcommentbutton" class="addcommentbutton" value="post" disabled/>     </div>     <span class="countdowncommentlength"></span> </form> 

here ajax success looks like:

$this = $(this);  if (response.commentsuccess === true) {     $this.closest('.addcomment').prev().append("appended comment");     $targetform.find('.addpostcomment').val('');     $(".nocomments").remove();     $(".commentsholder").scrolltop($(".commentsholder")[0].scrollheight); } 

this works fine if remove .prev , using prepend so:

  $this.closest('.addcomment').prepend("appended comment"); 

but orders comments incorrectly. if remove .prev , .append comment gets appended under form expect.

have tried lots of combos, cant find way works. note, there multiple forms on each page this.


Comments

Popular posts from this blog

visual studio - vb.net filter binding source by time -

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -