views:

18

answers:

1

Here's my code:

$('.reply').click(function() {
 $leftwrap = $(this).parent();
 $comment = $(leftwrap).parent();
 $id = $comment.attr('id');
 if($(this).siblings('.reply-form').length == 0) { //check whether or not the form as been initiated yet
 $(this).parent().append('<?php $replytimestamp = strtotime("now"); ?>
    <form class="reply-form" action="/scripts/reply-process.php" method="post">
    <input type="hidden" name="replytimestamp" value="<?php echo $replytimestamp; ?>">
    <input type="hidden" name="replyto" value="'+ $id +'">
    <label for="name" class="reply-label">Name</label>
    <input type="text" name="name" class="reply-input">
    <label for="message" class="reply-label">Reply</label>
    <textarea name="message"class="reply-ta"></textarea>
    <input class="reply-submit" type="submit" name="submit" value="submit" />
    </form>'); 
 $(this).siblings('.reply-form').hide();
 $(this).siblings('.reply-form').slideDown();
} else $(this).siblings('.reply-form').slideToggle(); //if it is, toggle it

});

When ever I click on '.reply' nothing happens, no slide, nothing. I couldn't find anything in Firebug. So any idea what's up? Thanks!!

+2  A: 

I would suggest always using brackets for your if statements, but regardless, your problem is here:

$leftwrap = $(this).parent();
$comment = $(leftwrap).parent();

If you are going to do it that way, it would need to be:

$leftwrap = $(this).parent();
$comment = $leftwrap.parent();

The $ variable isn't magic, its part of your variable name, so you gotta include it.

Alex Sexton
ok, I never did have a clear understanding of when to use the "$". Thanks!!
WillyG