i have comment/reply system.all divs closed.user clicks on comment want reply to.div opens when clicked.user replies comment.the reply gets sent database.jquery/ajax fetches the reply message , loads closes divs user replied comment.
jquery not showing selected divs (after page load)???
comment/reply code:
<div class='box'> ---- comments database code ---- </div> <div class='feedback'> ----- feedback database code --- </div> <div class='replymsg'> <form class=".replyform"> <textarea class="replytext" ></textarea> <button class="replybutton" data-value="<?php echo $commentid; ?>">submit</button> </form> </div> <div class="s"></div> jquery (open box ie. divs not working):
$(document).ready(function() { $(".replybutton").on("click", function(e) { e.preventdefault(); var id = $(this).data("value"); // id comment id can reply comment var replytext = $(this).prev().val(); var foo = this; $.post("reply.php", { commentid: id, reply: replytext }, function(data) { $("#result").html(data); $("textarea").val(""); // load page open box $("#commentpage").load("comments.php", function() { $(foo).parents(".replymsg").prev(".feedback").show(); }); }); }); }); //hides reply divs,opens form when comment box clicked $(document).ready(function() { $(".feedback").hide(); $(".replymsg").hide(); $(".box").on("click", function() { $(this).nextuntil(".s").toggle(); $(".box").disableselection(); }); }); #commentpage div created on script page.
Comments
Post a Comment