jquery.lazy icon indicating copy to clipboard operation
jquery.lazy copied to clipboard

JS Error When Using on Cloned Template

Open simonferndriger opened this issue 3 years ago • 2 comments

When using $e = $('template').contents().clone() as an element and appending it with $('body').append($e), calling $e.Lazy() afterwards triggers a JS error "Cannot call .toLowerCase() of undefined".

simonferndriger avatar Aug 16 '22 19:08 simonferndriger

Isn't a cloned element in jQuery a virtual Element? So don't you need to select the element after appending it to get the correct instance?

$e = $('template').contents().clone();
$('body').append($e);
$('clonedTemplateSelector').Lazy();

dkern avatar Aug 17 '22 06:08 dkern

That could be, however, with jQuery I can perform all regular acitons on that virtual element, so I don't see any reason why this should not be the case here... I could save an additional select and thereby improve performance.

simonferndriger avatar Aug 17 '22 16:08 simonferndriger

I close this, more of an edge case and I will not invest into it actually.

dkern avatar Sep 07 '23 13:09 dkern