jquery - Delete button in datatables rows not binding correctly on init and fnDrawCallback -


i have delete button in each row of table uses ajax json array , load data. .on() click event outside of fndrawkcallback in footer of page. thought putting callback fix hasn't.

each time table loads first init, redraw adding or deleting rows, when click delete button in row top first row deleted. why on click event bound row's delete button?

the delete button has .remimg class, button loading table json array key value.

thanks

  var otable =  $('#sss').datatable({         "olanguage": {             "semptytable": "no data"         },         "bprocessing": true,         "bserverside": true,         //"aadata": testdata,         "sajaxsource": 'http://example.com/sss.php',         "aocolumns": [     { "mdataprop": "date" },     { "mdataprop": "action_buttons","bsortable": false }      ],     "fndrawcallback": function( osettings ) {            $(document).on("click", ".remimage", function(e) {          jquery.ajax({             type: 'post',             url: 'http://example.com/sss.php',             data: {                 action: 'delete_post',                 att_id: jquery('#att_remove').val(),                 _ajax_nonce: jquery('#nonce').val(),                 post_type: 'sss'             },             success: function( html ) {                 alert( html );                 $('#sss').datatable().fnreloadajax();                            }         });     return false;     });         } }); 

att_id: jquery('#att_remove').val(),

this target first #att_remove value on page, first row being deleted regardless of trigger event from.

use method access value doesn't rely on id selector , should hope for.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -