Y
Y
Yuriy2019-07-17 12:58:40
Google
Yuriy, 2019-07-17 12:58:40

Bitrix & Lazy Load Images and Asynchronous Content Loading?

Through OnEndBufferContent , I return src back to all tags in JS after loading. Everything works fine, loading by scroll and resize is not needed. But 2 problems appeared 1. The site has loadable Ajax content, these are product blocks and the cart itself and others, respectively, there the data-src does not change through JS, what about asynchronous content loading in this case? Maybe Bitrix has an event after Ajax execution? tried this<img src заменил на <img data-src

BX.addCustomEvent('onAjaxSuccess', function () { console.log("test onAjaxSuccess"); })
doesn't work...
2. There are image blocks, sliders, backgrounds, and so on. they have pictures in the background style="background-image:" what to do with this moment? also add style="data-background-image:" or even cut out this property and put it in the tag attribute? type
<div style="background-image:url(...) ..."   --->   <div data-background-image="src.url" ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dcode, 2019-07-17
@dcode

1) OnEndBufferContent fires on ajax requests. At least in the standard Bitrix templates, as well as the onAjaxSuccess event (you can put any demo solution out of the box and test it). In this case, the first argument to onAjaxSuccess is the result of the request. If all this does not happen, then BX.ajax is not used.
2) And this depends entirely on the plugin you are using for lazy loading.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question