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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:37:24+00:00 2026-05-30T07:37:24+00:00

I get some bug trying to manage table data (with the available languages). Here

  • 0

I get some bug trying to manage table data (with the available languages). Here is what I have:

HTML:

<input type="button" id="add_language" value="Add Language" />
    <table>
        <tbody id="languages">
                                            <tr>
                            <td><div class="input text"><input type="text" id="Setting3Value3Language" rel="" value="English" name="data[Setting][3][value][3][language]"/></div></td>
                            <td><div class="input text"><input type="text" id="Setting3Value3Alias" rel="" value="eng" name="data[Setting][3][value][3][alias]"/></div></td>
                            <td/>
                            <td><button class="delete-lang">Delete</button></td>
                        </tr>
        </tbody>
    </table>

And jQuery:

$("#add_language").click(function(){
    var langId = langId + 1;
    var row ='<tr><td><div class="input text"><input type="text" id="Setting3Value'+langId+'Language" rel="" value="" name="data[Setting][3][value]['+langId+'][language]"/></div></td><td><div class="input text"><input type="text" id="Setting3Value'+langId+'Alias" rel="" value="" name="data[Setting][3][value]['+langId+'][alias]"/></div></td><td></td><td><button class="delete-lang ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" role="button" aria-disabled="false" title="Delete"><span class="ui-button-icon-primary ui-icon ui-icon-trash"/><span class="ui-button-text">Delete</span></button></td></tr>';
    $('#languages').append(row);
     return false;
});

$( ".delete-lang" ).button({
            icons: {
                primary: "ui-icon-trash"
            },
            text: false
        });

$( ".delete-lang" ).click(function(event){
    event.preventDefault();
    $(this).parents('tr').first().remove();
});

For the moment it is working except that for the delete button – when deleting a row that just has been inserted I get the form submited, it does not run event.preventDefault(); for the newly added row and submits the form. How to fix this?

Also I should add some kind of sorting the rows but also sorting them the name value inside the inputs should change. How to make the sortable event to change the input names?

I am not sure that this is the best way for managing the data inside a table but if there is better and easy one – please suggest.

  • 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-30T07:37:25+00:00Added an answer on May 30, 2026 at 7:37 am

    For rows that are added dynamically (ie. not available to the DOM on page load) you need to delegate the events to a static parent element. If you’re using jQuery 1.6 or older, you use delegate(), 1.7 or newer, you use on().

    Try this:

    $("#languages").delegate(".delete-lang", "click", function(event) {
        event.preventDefault();
        $(this).parents('tr').first().remove();
    });
    

    or in jQ1.7:

    $("#languages").on("click", ".delete-lang", function(event) { 
        // rest of your code....
    

    This is assuming that the tbody#languages element in your code is not appended via jQuery. If it is, try a different selector.

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

Sidebar

Related Questions

I am trying to get some XML data with LINQ, but running into a
I am trying to get some accurate runtime comparisons of PHP vs Python (and
I'm trying to get some code working that a previous developer has written. Yep,
So I'm trying to get some code that is written for gcc to compile
I was recently trying to find a bug in some scripting and I discovered
I am trying to make a form with some dynamic behavior. Specifically, I have
I keep getting the following error when trying to parse some html using BeautifulSoup:
i am trying to scrape some data from this site : http://laperuanavegana.wordpress.com/ . actually
Never had problems with centering divs before but I have been trying to get
To get some smooth graphics, I want to draw oversampled by factor 2 and

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.