Skip to content

Commit

Permalink
fix jquery + remove once
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed May 24, 2022
1 parent 8bc3a00 commit 0f32a29
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/src/legacy/TabSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ $.entwine('ss', function($){
*/
triggerLazyLoad: function(panel) {
panel.find('.grid-field--lazy-loadable, .lazy-loadable').each((i, el) => {
const $el = e(el);
const $el = $(el);
// Avoid triggering all lazy loadable scripts when using nested tabs
if ($el.closest('.ss-tabset, .cms-tabset').is(this)) {
// Trigger dedicated entwine function (see GridField.js)
if(typeof $el.lazyload === 'function') {
$el.lazyload();
}
// Also dispatch a native event for scripts not using entwine
el.dispatchEvent(new Event("lazyload"), { once: true });
// It should be listened to only once
el.dispatchEvent(new Event("lazyload"));
}
});
},
Expand Down

0 comments on commit 0f32a29

Please sign in to comment.