Sunday, 15 September 2013

Comments only posting to most recent status update

Comments only posting to most recent status update

The news feed on the sites dashboard I'm working on has multiple items
from different users; and can also be commented on. However, whenever you
write a comment under each post, it only posts to the post at the top of
the feed (the most recent one). Comments are posted instantly by pressing
the enter key, which then runs this JS code which is on the index.php
page.
$(function(){
$('#comment_body').live( 'keypress' , function (e) {
var boxVal = $(this).val();
var sendTo = $('#to_id').val();
if ( e.keyCode == '13' ) {
e.preventDefault();
$.post( 'instantcom.php' , { 'comment_body' : boxVal ,
'activity_id' : sendTo } , function () {
// reload data or just leave blank
} );
$('#comment_body').val('');
}
} );
});
Then, the HTML for the comment box on each post is as follows:
<p align="center" style="height:45px;">
<input type="text" name="comment_body" id="comment_body"
style="margin-top:12px;border:1px solid blue
!important;width:329px;height:21px;" />
<span class=" glyphicons-icon camera"
style="position:relative;bottom:50px;left:155px;"></span></p>
<input name="type" type="hidden" value="a" />
<input name="activity_id" id="to_id" type="hidden" value="' . $act_item_id
. '" />
The ' . $act_item_id . ' is just a PHP variable which contains the unique
ID of the status update.
So then, any ideas as to why comments are only posting to the most recent
posts instead of the ones they're meant to post to?

No comments:

Post a Comment