For some reason the following script throws error "Error: Syntax error, unrecognized expression: commentscontainer_(post_id)".. does any one know why ? is it a syntax error ?
$(document).ready(function() {
var msg = '.text-holder';
$('.time').timeago();
$('.text-holder').autosize();
$('#post_comment').click(function() {
$(msg).focus();
});
$('.text-holder').keypress(function(e) {
var postID = this.id.replace('post_', '');
if(e.which == 13) {
var val = $(msg).val();
$.ajax({
url: 'auth/classes/comments.php',
type: 'GET',
data: 'token=<?php echo $token; ?>&msg='+escape(val),
success: function(data) {
$(msg).val('');
$(msg).css('height','14px');
$('.commentscontainer_'+postID).append(data);
$('.time').timeago();
}
});
}
});
This is pretty munch the html
<div class="commentscontainer_['post_id']"></div>
I have another script.. is it clashing with this ?
$(document).ready(function(){
$(".comment_box").hide();
$('.slider').on('click',function(){
var flag = $(this).data('flag'),
postID = this.id.replace('post_', '');
$('#' + postID).slideToggle();
if (!flag) {
$.ajax({
url : 'auth/classes/comments.php',
data: {post_id: postID}
}).done(function(data) {
$('.commentscontainer_'+postID).replaceWith(data);
$('.time').timeago();
});
}
$(this).data('flag', !flag)
});
});