Magento2 AJAX – Use

Best Answer

It is very easy to solve.

Look in this line: https://github.com/magento/magento2/blob/develop/lib/web/mage/mage.js#L93

Here mage waiting when you insert html content with ajax: "text/x-magento-init".

Example:

you insert to

<div id="gallery"></div>
$('#gallery').html(content)

After call magento:

$('#gallery').trigger('contentUpdated');