Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery add rows then remove them if not needed
    primarykey
    data
    text
    <p>I am struggling with setting up jquery to insert new table rows and then remove them if I dont need them. </p> <p>For example: </p> <p>I have two buttons on a each table row, like so: </p> <pre><code> -------------------------------------- |Add / Remove | Name | Id | Color | -------------------------------------- |Add / Remove | Shirt | 1 | Blue | -------------------------------------- |Add / Remove | Shirt | 2 | Red | -------------------------------------- </code></pre> <p>When I click the "Add" button it will use ajax to go out and grab data and insert rows after the current row. Here is my code (this works fine):</p> <pre><code> $(function() { $('#example').on('click', 'input[name="cmdAddRow"]', function() { var curRow = $(this).closest('tr'); $.ajax({ cache: false, type: 'POST', url: '{{ path('inventory_low_test_asin_data') }}', data: '', success: function(data) { var newRow = data.htmlData; curRow.after(newRow); } }); }); }); -------------------------------------- |Add / Remove | Name | Id | Color | -------------------------------------- |Add / Remove | Shirt | 1 | Blue | -------------------------------------- | Inserted | A | 1 | Blue | - Need to be able to remove this row -------------------------------------- | Inserted | B | 1 | Blue | - Need to be able to remove this row -------------------------------------- | Inserted | C | 1 | Blue | - Need to be able to remove this row -------------------------------------- | Inserted | D | 1 | Blue | - Need to be able to remove this row -------------------------------------- |Add / Remove | Shirt | 2 | Red | -------------------------------------- </code></pre> <p>Now this is the tricky part, if I dont need those rows of data which were inserted (sometimes it will return upwards of 20 rows which are inserted after the current row), I will need to be able to remove all of those rows that were inserted all at once (not one at a time). How is this handled when I click the "Remove" button for that row? I am not sure what to write for jQuery. </p> <p>Thanks so much for your help!!!! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload