Answer the question
In order to leave comments, you need to log in
How to get element just added from mustashe render via innerHTML?
there is a function that renders some HTML on the page, how to get its DOM, since the string
console.log(document.getElementById('helpdesk'));
naturally returns null, the mainUtilites.mustasheItemABuild function fills the specified HTML block according to the mustache template using innerHTML
helpdeskCreate: function (data, callbackLoad) {
let dataBuild = {
id: 'helpdesk',
title: 'FAQ',
description: data
};
mainUtilites.mustasheItemABuild('hd__modal_container', '/site/get-template/?tmp=modal', dataBuild);
//инициализация модального окна
userUI.modalUIInit('hd__modal_container');
console.log(document.getElementById('helpdesk__modal'));
callbackLoad.empty();
},
Answer the question
In order to leave comments, you need to log in
width: calc(100% - 50px);
Similarly, I make up any adaptation without js.
function waitForElementToDisplay(selector, callback, checkFrequencyInMs, timeoutInMs) {
let startTimeInMs = Date.now();
(function loopSearch() {
if (document.querySelector(selector) !== null) {
callback();
return;
}
else {
setTimeout(function () {
if (timeoutInMs && Date.now() - startTimeInMs > timeoutInMs)
return;
loopSearch();
}, checkFrequencyInMs);
}
})();
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question