delete single row

delete single row

kortexkortex Posts: 5Questions: 0Answers: 0
edited June 2013 in DataTables 1.9
This is the relevant PHP:

[code]$sOutput .= '" Delete ",'; [/code]

This results in output of:

[code]Delete [/code]


What I would like to do is remove that row from the list, and then write a message above the table to the effect of "You have successfully removed this item."

jQuery I wrote is not working:

[code]$('a.deleteRow').click(function() {
$(this).parents('tr').remove();
});[/code]

actually there is no reaction for click.

I have tried this one also no reaction too.

[code]$('a.deleteRow').click(function() {
alert("wait...");
});[/code]

Anyone have some advice? where is Problem?

Replies

  • aaronwaaronw Posts: 89Questions: 3Answers: 4
    '.' is the jquery selector for a class. You want # or in this case '#deleteRow'
  • kortexkortex Posts: 5Questions: 0Answers: 0
    edited June 2013
    sorry, my fault. i edited my post with correct output.

    when i click to delete link, still no reaction..

    [code]
    $(document).ready(function() {


    $('#datatable').dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "sPaginationType": "full_numbers",
    "sAjaxSource": "includes/list.php",
    "sServerMethod": "POST"
    });



    $('a.deleteRow').click(function() {
    alert("wait...");
    });


    });
    [/code]
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    > "bServerSide": true

    If you want to delete the row, you need to delete it at the server and then call fnDraw. Reason being, you are using server-side processing - so the data is at the server.

    Allan
  • aaronwaaronw Posts: 89Questions: 3Answers: 4
    I misread above, but you have "classs" in the HTML for the deleteRow
  • kortexkortex Posts: 5Questions: 0Answers: 0
    i know data is at the server.

    but click function does not respond

    when i click delete link nothing happens, should give an alert but there is no alert..

    sorry for my english :(
  • kortexkortex Posts: 5Questions: 0Answers: 0
    edited June 2013
    @aaronw omg still my fault.

    js like this:

    [code] $(document).ready(function() {

    $('#datatable').dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "sPaginationType": "full_numbers",
    "sAjaxSource": "includes/list.php",
    "sServerMethod": "POST"

    });


    $('.deleteRow').click(function() {
    alert("wait...");
    });


    });

    [/code]


    output like this:

    [code]

    lorem ipsum
    lorem ipsum
    lorem ipsum
    lorem ipsum
    1
    delete
    [/code]

    when i click delete no alert..

    but when i put this delete link in my page manuelly (not php output) function working good..
  • kortexkortex Posts: 5Questions: 0Answers: 0
    problem solved. thanks @allan & @aaronw

    here is solution: http://stackoverflow.com/questions/17087881/click-function-in-datatables-action-menu

    I worked two days and look at the answer :))
This discussion has been closed.