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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:16:08+00:00 2026-06-09T20:16:08+00:00

In my project, I’m working on a function which deletes rows from a table

  • 0

In my project, I’m working on a function which deletes rows from a table and also from the database using .ajax(). I’ve created my function for when the user clicks on the delete button. As you can understand, there a several rows and every row has its own delete button.

Now, when the user clicks on one of them for the first time, a popup modal appears with the question if he/she is sure about deleting the item. When he/she clicks yes, the popup disappears and the row fades-out. This all works perfectly, but…

When you click on a second delete button without refreshing the page, JavaScript fires off the current requested delete (and id) + de previous one. If you do it for a third time, it will fire of the current one and the two previous ones.

I tried to empty the current var $(this).attr('data-page-id');, but it still does the same thing when the .ajax() success function gets fired.

$('a.btn-page-delete').click(function() {

    var curPageId = $(this).attr('data-page-id');

    $('#delete-page').modal('show');

    $('a#action-confirm').click(function() {

        $.ajax({

            type       : 'POST',
            url        : '/pages/async/delete',
            dataType   : 'json',
            data       : { page : curPageId },
            success    : function(data) {

                $('#delete-page').modal('hide');

                console.log(curPageId);
                console.log(data);

            },
            error   : function() {}

        });

    });

});
  • 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-06-09T20:16:09+00:00Added an answer on June 9, 2026 at 8:16 pm

    When your outer click event handler gets called

    $('a.btn-page-delete').click(function() {
    

    it’ll .bind() another click event handler to $('a#action-confirm') everytime. So, everytime the outer event is executed you add one more event handler.

    I’m sure you can and should re-build and construct this in a better way, but in the present state your only choice is to .unbind() / .off() the inner click handlers, like

     $('a#action-confirm').off('click').click(function() {
    

    that will remove any click event handler bound via jQuery previously.

    Ref.: .off()

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

Sidebar

Related Questions

Project I'm working on uses jQuery. I have a series of Ajax calls being
project: Using VB.NET to build a winforms database interface and work-automation app. I am
project: Using VB.NET to build a winforms database interface and work-automation app. I am
Our project uses XJC to generate Java classes from an XSD. I'm using JAVA
My project is currently using a svn repository which gains several hundred new revisions
Project: ASP.NET 3.5 with C# I have this much :- A table which used
Project explained below is created and built using Eclipse Juno(4.2). We receive the following
The project that I am working on (Node.js) implies lots of operations with the
This project was coped almost exacatly from the example on the admob page but
This project is in Obj-C for iphone. I'm using the double float version of

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.