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 7596189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:51:34+00:00 2026-05-30T21:51:34+00:00

I have a button on my page which adds row by row on each

  • 0

I have a button on my page which adds row by row on each click.
I use this code:

$('#addCnt').live('click', function () { .. };

Problem is when I reload the part of the page together with that code, it registers the handler again, so when button is clicked after that it appends N number of rows, where N = number of total page reload.

How can I prevent that?

  • 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-30T21:51:36+00:00Added an answer on May 30, 2026 at 9:51 pm

    Within a given page, you need to make sure that your code to attach the event handler is never run more than once. So this code:

    $('#addCnt').live('click', function () { .. };
    

    should not be run multiple times.

    If you can’t restructure your code to prevent this from being run more than once, then you can create your own global flag to protect it:

    if (typeof window.addCntProtection == "undefined")  {
        window.addCntProtection = false;
    }
    if (!window.addCntProtection) {
        $('#addCnt').live('click', function () { .. };
        window.addCntProtection = true;
    }
    

    Incidentally, jQuery has deprecated the use of .live() and it is no longer recommended for any version of jQuery. They recommend you use .on() for jQuery 1.7+ or .delegate() for earlier versions of jQuery.

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

Sidebar

Related Questions

I have an ASP.NET page which has a button it it. The button click
I have a <button> element which adds an element to my page when clicked.
In my dgv I have a DataGridViewButtonColumn which adds a delete row button to
I have small page which has label, DropDownList and a submit button. <div> <asp:label
I have google analytics on my site. One page has a button which when
I have a page with a button that when I click, it retrieves data
I have an asp.net page with a button. This button generates and inserts a
I have a repeater on my page which I use to display a list
I have an html page with one or more textareas, each of which has
this is my scenario: i have a page with a placeholder. the page adds

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.