'Ajax refresh (filter) breaks jQuery

I have some jQuery to insert some items into a list with a filter on those items. Once I apply the ajax filter using a plugin (Filter everything), on reload my jQuery function stops working and the only way to make it work is by refreshing the page. Does anybody know how I can overcome that?

                
            jQuery( document ).ready(function() {    

            jQuery('.add-pe').on('click', function() 
               
               {
               
                   var dataId = jQuery(this).attr("data-id")
                   var title = jQuery(this).attr("title")

                jQuery(".values-list").append('<li><input type="hidden" name="acf[field_61e58083d6d49][]" value="' + dataId + '"><span data-id="' + dataId + '" class="acf-rel-item">' + title + '<a href="#" class="acf-icon -minus small dark" data-name="remove_item"></a></span></li>');
              
                   jQuery('[id=' + dataId + ']').append('<p class="success"><i style="color:green;" class="fa fa-check-circle" aria-hidden="true"></i> Added to list- remember to submit it</p>')
                   
                   jQuery(".success").fadeOut(9000);
          
               });
            });



Solution 1:[1]

I managed to fix it using the .ajaxComplete(...) function, see below the revised code:

jQuery( document ).ajaxComplete(function() {    
    jQuery('.add-pe').on('click', function() {
        var dataId = jQuery(this).attr("data-id")
        var title = jQuery(this).attr("title")

        jQuery(".values-list").append('<li><input type="hidden" name="acf[field_61e58083d6d49][]" value="' + dataId + '"><span data-id="' + dataId + '" class="acf-rel-item">' + title + '<a href="#" class="acf-icon -minus small dark" data-name="remove_item"></a></span></li>');
              
        jQuery('[id=' + dataId + ']').append('<p class="success"><i style="color:green;" class="fa fa-check-circle" aria-hidden="true"></i> Added to list- remember to submit it</p>')
                   
        jQuery(".success").fadeOut(9000);
    });
});

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tyler2P