Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6826677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:10:34+00:00 2026-05-26T22:10:34+00:00

first post, im using the cakephp framework with ajax to create a reply button.

  • 0

first post, im using the cakephp framework with ajax to create a reply button. the problem is that when a user clicks the reply button more then once the textbox keeps loading. how can i make it toggle so that when a user clicks it for the second time it closes the reply text box. right now i can just disable the button with thiss.remove(); but id rather close the text box. my code is below . thanks

<script type="text/javascript">
jQuery('.reply-button').live('click', function() {
    var a = jQuery(this).data('comment_id');
    var b = jQuery(this).data('video_id');
    var c = jQuery(this).data('comment_quote');
    var d = jQuery(this).data('reply_name');
    var e = jQuery(this).data('quote_body');
    var f = jQuery(this).data('topic_name');
    var thiss = jQuery(this);
    jQuery.ajax({
        type: "POST",
        url: "<?= $this->Html->url(array('controller' => 'comments', 'action' => 'reply')); ?>",
        data: { comment_id: a, video_id: b, comment_quote: c, reply_name: d , quote_body: e , topic_name: f },
        success: function(html) {
            thiss.parent().parent().parent().append(html);
        }
    });
});

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:10:34+00:00Added an answer on May 26, 2026 at 10:10 pm

    If your textbox has an id or class attribute I’d use that to determine if it’s visible/hidden/already loaded and based on that hide/show/load it.

    For example say the textbox has an id of reply you can do:

    jQuery('.reply-button').live('click', function() {
    
        // Check if the textbox is on the page or if we need to load it via an ajax call
        if (jQuery('#reply').length == 0)
        {
            // The textbox isn't loaded on the page so call the ajax and append it     
            var a = jQuery(this).data('comment_id');
            var b = jQuery(this).data('video_id');
            var c = jQuery(this).data('comment_quote');
            var d = jQuery(this).data('reply_name');
            var e = jQuery(this).data('quote_body');
            var f = jQuery(this).data('topic_name');
            var thiss = this;
    
            jQuery.ajax({
                type: "POST",
                url: "<?= $this->Html->url(array('controller' => 'comments', 'action' => 'reply')); ?>",
                data: { comment_id: a, video_id: b, comment_quote: c, reply_name: d , quote_body: e , topic_name: f },
                success: function(html) {
                    thiss.parent().parent().parent().append(html);
                }
            });        
        }
        else
        {
            // The textbox is on the page so check if its visible/showing
            if (jQuery('#reply').is(':visible'))
            {
                // The textbox is visible so hide it
                jQuery('#reply').hide();
            }
            else
            {
                // The textbox is hidden so show it
                jQuery('#reply').show();
            }
        }
    });
    

    Edit: I also change your var thiss = jQuery(this); to var thiss = this; as this is already a jQuery object so it doesn’t need to go through jQuery(this) to turn it into one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First post here... I normally develop using PHP and Symfony with Propel and ActionScript
This is my first post here. I have a problem. I need to take
This is my first post, but I've loved using this site as resource for
Hey,firends,This is my first post. I'm just begin to using Gcc to compile java,and
My first post here :) I am having a problem with the following C++
This is my first post, but I have been using this site for a
First post, but long time browser :) So here's my problem: Basically I have
first post don't hurt me :) I am using a BorderLayout with the usual
this is my first post here. I'm using an existing Flash widget but would
This is my first post, but I've been using the site for years. However,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.