I'm using a jQuery isotope. I found out how to reLayout after you click when it displays a textarea for a comment.
But my problem lies with jQuery when you click the comment button, it opens all of the comment boxes on the page instead of the single comment.
I was wondering if it were possible to put my COMMENT_ID in the script so that it only opens a single box instead of all of them.
my code: (that doesn't work)
$('.commentopen').click(function() {
$('.comment '<php echo $LOGGER_ROW['COMMENT_ID'] ?>').slideDown(1000, function() {
$('#container').isotope('reLayout');
});
});
Any help is appreciated.
When rendering your HTML, if you give each comment an href attribute, then you can use jquery attr()
function to grab that reference and only reveal that comment.
For example:
$('.comment').click(function() {
var id = $(this).attr('href');
$('.comment#' + id).slideDown(1000, function() {
$('#container').isotope('reLayout');
});
});
I've change your code a bit so that all comments are treated as .comment class elements.
Each comment also has a unique id with it, and so the correct one slides open, of all comments available.
Here is a working solution: http://jsfiddle.net/HDBwY/
Hope it helps.
$('.commentopen').click(function() {
var id = $(this).attr('id');
$('.comment' + id).slideDown(180, function() {
$('#container').isotope('reLayout');
});
});
heres what i ended up doing (which still didnt work) i gave each text area (.comment) an id, and then i gave the comment link to open the textarea(.commentopen) the exact same id, then using the this function, i obtained the same id as i use for comments. and in the html, they seem to match up row for row. but it still desnt seem to work.
Your syntax is bad. Consider this snippet:
$('.comment '<php echo $LOGGER_ROW['COMMENT_ID'] ?>').slideDown
When you substitute the PHP, it become:
$('.comment 'x').slideDown
There's an extra single quote there. Perhaps it should be a pound instead?
$('.comment #<php echo $LOGGER_ROW['COMMENT_ID'] ?>').slideDown