Skip to content

Commit

Permalink
Add mutations observer to initialize user initials added through ajax
Browse files Browse the repository at this point in the history
Co-authored-by: Javi Martín <javim@elretirao.net>
  • Loading branch information
Senen and javierm committed May 12, 2020
1 parent db0bd6f commit c24597c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/assets/javascripts/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
"use strict";
App.Users = {
initialize: function() {
var observer;
$(".initialjs-avatar").initial();
observer = new MutationObserver(function(mutations) {
$.each(mutations, function(index, mutation) {
$(".initialjs-avatar", $(mutation.addedNodes)).initial();
});
});
observer.observe(document.body, { childList: true, subtree: true });
}
};
}).call(this);

0 comments on commit c24597c

Please sign in to comment.