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

  • Home
  • SEARCH
  • 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 914645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:45:04+00:00 2026-05-15T17:45:04+00:00

I have a question concerning using the toggle function. I have a template that

  • 0

I have a question concerning using the toggle function. I have a template that is being populated at the end of an AJAX call with data returned from a web service. What I’m trying to accomplish is load the onClick function so that a hidden textbox will be shown and toggled to be hidden on the next click.

What’s happening is that when I click the link once everything’s fine the textbox shows and hides. But if I keep clicking the Edit link the textbox will show and hide the number of times that the link has been clicked (ie. I click the link for the second time it fadesIn/Out twice, the third time it fades In/Out 3 times, etc).

Would someone please look at my code and help me?

Thanks!

PS. I was also trying to toggle the link to go from “Edit” to “Cancel” as well; I haven’t spent much time on that but if you want to throw me a bone on that too, I’ll take it! 😉

 function showSCs(data) {
   $('#sometmpl3').tmpl(data.d)
     .appendTo($('#subCats'))
     .find(".aEdit").toggle(function() {
       $(this).click(function() {
         $(this).parent().find('.scEditHide').fadeIn();
         $(this).text = "Cancel";

         return false;
       });
     }, function() {
       $(this).click(function() {
         $(this).parent().find('.scEditHide').fadeOut();

         return false;
       });
     });
 } 

The structure of the elements referenced is:

 <div> 
  <h4>${ProblemSubCategory}</h4>

  <input id="text${ProblemSubCategoryID}" type="text" value=${ProblemSubCategory}   class="scEditHide"/>

  <a href="#" id="${ProblemSubCategoryID}" class="aEdit">Edit</a>
  <a href="dummyWebservice.asmx\DeleteSC\${ProblemSubCategoryID}">Delete</a>
</div>
  • 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-15T17:45:05+00:00Added an answer on May 15, 2026 at 5:45 pm

    Pointy is right about setting up the onClick handler. What you are doing now, is adding a new handler (that will be fired every time you click) to the element. That way, the first time you click it will add a handler and fire it. The second time you click, it will add yet another handler, and then fire both that and the one previously added.

    You should change your code to something like this.

    function showSCs(data) {
        $('#sometmpl3').tmpl(data.d)
        .appendTo($('#subCats'))
        .find(".aEdit")
        .toggle(
            function() {
                $(this).parent().find('.scEditHide').fadeIn();
                $(this).text("Cancel");
                return false;
            },
            function() {
                $(this).parent().find('.scEditHide').fadeOut();
                $(this).text("Edit"); //added: set text back to edit
                return false;
            }
        );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 489k
  • Answers 489k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Could it be that your header file (.../taucs/src/taucs.h), which contains… May 16, 2026 at 8:56 am
  • Editorial Team
    Editorial Team added an answer Try this applescript: tell application "Safari" set miniaturized of window… May 16, 2026 at 8:56 am
  • Editorial Team
    Editorial Team added an answer Given that you want to determine ranges of consecutive date… May 16, 2026 at 8:56 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I've been using Jquery for some time now and I have a question concerning
I have a question concerning the performance, reliability, and best practice method of using
I have a question concerning the class generation in Visual Studio 2008. I use
Just finished reading Crockford's JavaScript: The Good Parts and I have a question concerning
I have a strange question concerning subroutines: As I'm creating a minimal language and
I have opended a question about repeated parameter-checks in public methods. The result there
This is a general question concerning technology decisions for a product development. My aim
Concerning headers in a library, I see two options, and I'm not sure if
EDIT : I don't know in advance at which column my digits are going

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.