mutation observateur production boucle infinie

J’écris une fonction en utilisant l’observateur de mutation avec jQuery pour enregistrer les modifications apscopes au DOM, en particulier lorsqu’un nouveau nœud est ajouté afin que je puisse modifier son contenu:

$("SELeCTOR GOOD" ).click(function(){ var targetNode = $(this).find('.content').get(0); var config = { atsortingbutes: true, childList: true, subtree: true, atsortingbuteOldValue: true }; // Callback function to execute when mutations are observed var callback = function(mutationsList) { for(var mutation of mutationsList) { if (mutation.type == 'childList') { var courses = $(targetNode).find('.courses').get(0); $(courses).find('.coursebox.clearfix').each(function( index,item ) { var attacherURL = $(item).find('.coursename a').attr('href'); var moreInfoURL = 'More info'; var oldHTML = $(item).find('div.moreinfo').html(); var newHTML = moreInfoURL + oldHTML; //this following line is supposed to replace the html, but it creates an infinite loop $(item).find('div.moreinfo').html(newHTML); //end }); } else if (mutation.type == 'atsortingbutes') { console.log('The ' + mutation.atsortingbuteName + ' atsortingbute was modified.'); } } }; 

J’ai aussi essayé append / prepend, mais tout crée la même boucle infinie. Comme d’habitude, toute aide est grandement appréciée.

Cordialement