I'm using a wordpress plugin to add classes to comments as 'editors' picks'.
On the page I have two buttons, one to show the comments and one to show the editors picks. All is working just fine.
Code:-
$(document).ready(function () {
$("#editors-picks").on("click", function(e){
$("ol.commentlist li").not(".featured").fadeOut(); // fade out any comments that aren't 'featured'
});
$("#comments").on("click", function(e){
$("ol.commentlist li").not(".featured").fadeIn(); // fade all comments back in
});
});
The problem is comments dynamically added to the DOM tree(via ajax). After a new comment is added the function doesn't work. I thought using .on would fix this, but it does not.