I try to added HTML + RequireJS
to DIV
tag via ajax loading.
With content contain tags like <script type="text/x-magento-init">
or data-mage-init
attribute, It's easy to bind event using $('#selector').trigger('contentUpdated')
. In the case, it can be re-initialize on mage/apply/main
using function:
function init(el, config, component) {
require([component], function (fn) {
if (typeof fn === 'object') {
fn = fn[component].bind(fn);
}
if (_.isFunction(fn)) {
fn(config, el);
} else if ($(el)[component]) {
$(el)[component](config);
}
});
}
And I know we can be switch <script> require(...)</script>
on append HTML to <script type="text/x-magento-init">
.
But I want to try another way to re-init requirejs. Any ideas for this issue?
<script type="text/x-magento-init">
and don't bind new event for it.