Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

customJS and load window => Dom not fully ready apparently #338

Open
foulong opened this issue Mar 14, 2023 · 2 comments
Open

customJS and load window => Dom not fully ready apparently #338

foulong opened this issue Mar 14, 2023 · 2 comments

Comments

@foulong
Copy link

foulong commented Mar 14, 2023

Hello,

i wish to custom the title, with image ().
I use the option "customJs".

expected :
access title element and modify it

obtained :
impossible to access title element

It seems to dom is not fully loaded.
Below, Js code :

window.addEventListener("load", function () {
    console.log("Window onload event called.");
    /* 
    returns (Q : why "length: 0" ?) :
    .swagger-ui getElementsByClassName 
    HTMLCollection { length: 0 }
    0: <section class="swagger-ui swagger-container" data-reactroot="">​
    1: <div class="swagger-ui">
    length: 2
    */
    console.log(".swagger-ui getElementsByClassName", document.querySelector("#swagger-ui").getElementsByClassName("swagger-ui"));
    /* 
    returns :
    .swagger-ui getElementsByClassName undefined
    */
    console.log(
        ".swagger-ui getElementsByClassName",
        document.querySelector("#swagger-ui").getElementsByClassName("swagger-ui")[0],
    );

    // returns : null
    console.log(document.querySelector("#swagger-ui .info .title"));
});

Thx in advance for your help.

@sophie-pan
Copy link

any update ?

@d4cho
Copy link

d4cho commented Dec 5, 2023

I'm having the same issue.

I'm using customJS in my options.

I can't get any elements using querySelector or getElementBy...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants