C
C
CarloMarlo2022-02-12 19:46:27
css
CarloMarlo, 2022-02-12 19:46:27

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

2 answer(s)
D
Dark Hole, 2016-02-17
@Ketch

width: calc(100% - 50px);
Similarly, I make up any adaptation without js.

C
CarloMarlo, 2022-02-12
@CarloMarlo

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 question

Ask a Question

731 491 924 answers to any question