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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:09:24+00:00 2026-05-25T11:09:24+00:00

So I have a button inside a list row that is used to delete

  • 0

So I have a button inside a list row that is used to delete the row from the page (calls ajax stuff to delete the object represented by the row, but that’s not important for my question). The whole row is bound to a click event which would redirect to another page.

In other words, the containing row is click bound and the inner button is click bound, which is causing me problems since clicking the inner button also triggers the containing row click event (as it should).

I’ve tried binding a hover event for all delete buttons that unbinds the row click on mouseover, and rebinds it on mouseout, like this pseudocode below:

$('.delete-button').hover(
  function() {
    $('.list-row').unbind();
    $('.delete-button').bind('click', function() { /* delete action */ });
  },
  function() {
    $('.delete-button').unbind();
    $('.list-row').bind('click', function() { /* list row action */ });
  }
);

This isn’t working very well, and I’m convinced there is a better way to approach it. Should I take the button out of the containing list-row? It’s way easier to have it in there since my list row contains custom attributes that have data I need for the ajax calls and I can just var rid = $('.delete-button).parent().attr('row-id'); to get the data, but I’m not opposed to change 🙂

Thanks!

  • 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-25T11:09:25+00:00Added an answer on May 25, 2026 at 11:09 am

    In your click event handler for the button, you need to call e.stopPropagation(). This will prevent the event from bubbling up the DOM tree. More info here: http://api.jquery.com/event.stopPropagation/


    edit: you already accepted (thanks!), but maybe this code snippet would help explain some of the concepts better:

    $('.list-row').click(function() {
        /* list row action */
    });
    
    $('.delete-button').click(function(e) {
        // die, bubbles, die
        e.stopPropagation();
        // if you also need to prevent the default behavior for the button itself,
        // uncomment the following line:
        // e.preventDefault();
        // note that if you are doing both e.stopPropagation() AND e.preventDefault()
        // you should just `return false;` at the end of the handler (which is jQuery-
        // sugar for doing both of these at once)
    
        /* delete action */
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list box in my app and a button inside that list
I have a form loading inside my page and there is a button out
I have an list item with a button inside of it. The button is
I'd like to have X number of Ajax panels on my list page which
hi I have a radio button list inside a repeater , the repeater is
i have list view inside list view a button when i click button list
I have a list view which contains a button in each row of the
I have a very simple view that has a DropDownListFor and a Button inside
I have the create inside the table/list that Grails provides. Here is a pictures
I have a button inside an updatepanel. I have a PopupControlExtender linked to the

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.