I have php comment system like Facebook where user can post comment and reply. when I make 2 reply in a comment one after one then I cannot make 3rd reply in same comment. Also here cannot work emoticons slide and upload toggle. But can reply others comments. I cannot understand this type of jQuery behaviour!!! I also can't understand, can php create this type of problem?
For emoticons display yet I create review window behind textarea And make my textarea transparent. So here I used jQuery bind(). All comment and reply submit by AJAX.
When i going to reply 3rd time Its not work in same comment. But after refresh its work for more 2 reply only.
Here is some related jQuery:
$('.maintbox').on('keyup',function() {
$(this).css('height','auto');
$(this).css('height',Math.max(this.scrollHeight)+'px');
});
$('.replycom').livequery("click",function() {
var VID = $(this).attr('id').replace('replycom','');
$("#parent_id").attr("value", VID);
$("#replycom"+VID).bind("keyup", function() {
$("#replycom"+VID).html($(this).val());
$(".review"+VID).html(smilyMe($("#replycom"+VID).val()));
});
return false;
});
$('.showhide_emobox').livequery("click",function(){
var EID = $(this).attr("id");
$("#emobox"+EID).slideToggle();
});
$(".embtno").livequery("click",function(event){
var emotiText = $(event.target).attr("alt");
var EID = $(this).attr('id').replace('','');
var prevMsg = $("#replycom"+EID).val();
$("#replycom"+EID).val(prevMsg + emotiText);
$(".review"+EID).html(smilyMe($("#replycom"+EID).val()));
$('#emobox'+EID).fadeToggle();
});
my form:
echo'<div class="replyform"><ul>
<form action="" method="post" class="repfrm'.$rows['id'].'" id="prepfrm">
<fieldset id="cmntfs">
<input type="hidden" name="username" id="author" value="'.$_SESSION['username'].'"/>
<input type="hidden" name="url" id="url" value="" />
<div class="maintbox">
<div class="chat">
<div class="review'.$rows['id'].'" id="review"></div>
<textarea name="replycom" id="replycom'.$rows['id'].'" class="replycom" placeholder="Type your comment ..."></textarea>
</div>
<div align="right"><img src="images/envlop.png" width="25" alt="" class="uploadReply" id="'.$rows['id'].'" style="padding:2px;cursor:pointer;" />
<div class="em">
<img src="images/smile.png" id="'.$rows['id'].'" class="showhide_emobox"/>
<div id="emobox'.$rows['id'].'" class="emobox">
<img src="smilies/smile.gif" alt=":)" class="embtno" id="'.$rows['id'].'" />
<img src="smilies/sad.gif" alt=":(" class="embtno" id="'.$rows['id'].'" />
<img src="smilies/biggrin.gif" alt=":-D" class="embtno" id="'.$rows['id'].'" />
</div>
</div>
</div>
<input type="hidden" name="parent_id" id="parent_id" value="'.$rows['id'].'" />
<input type="hidden" name="tutid" id="tutid" value="'.$tutid.'" />
</form>
// Image upload system here
</div>
<button type="submit" name="submit" value="" id="repl'.$rows['id'].'" class="replyfrm">Post Reply</button>
</fieldset>
</ul></div>';