0

I have a problem with my delete action inside the datatables. My delete function won't working on second page after pagination.

I did $(this).off().on('click', '.btn_btn-danger_act-delete-member-maillinglist' , function(){ but it doesn't working and my button on first page also won't work.

$('.act-delete-member-maillinglist').each(function() {
  $(this).off().on('click', '.btn_btn-danger_act-delete-member-maillinglist', function() {
    var email = $(this).attr('data-email');
    var list = $(this).attr('data-list');
    Polaris.deleteMemberMailingList(list, email, function() {
      $('.container_list_member_mailinglist').html('<i class="fa fa-spinner fa-spin"></i>');
      Polaris.fetchDataMemberMailingList(lname, function() {
        $('#popupmembermailing').find('.container-loader').hide();
      });
    });
  });
});
Rory McCrossan
  • 306,214
  • 37
  • 269
  • 303
  • I don't think this is a duplicated question, @RoryMcCrossan, as his problem is a bad event management not dynamic elements event handling. You're using the off() method which clears all the event hooks created before and seems to be ignoring the on() method that it's placed after it. Try using just the on() method instead. – Jorge C.M Oct 02 '19 at 09:44
  • 1
    @JorgeC.M that could well be the case given the repeated `on()` calls in an `each()` loop, which is very odd. A solution is going to be hard to diagnose without a working example, though. – Rory McCrossan Oct 02 '19 at 10:00
  • now I'm using ```$('div').off().on('click', 'a.btn_btn-danger_act-delete-member-maillinglist', function() {``` and the delete button is working, but my close popup function won't work – Sherly Tanaya Oct 07 '19 at 03:05

0 Answers0