Doesn't fire when loaded asyncronous #156

Closed
mcguffin opened this Issue May 2, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@mcguffin

mcguffin commented May 2, 2014

Looks very much like the DOMContentLoaded event has already being fired, when an asyncronously loaded script is executed.

Replacing

if (document.addEventListener) {
    return document.addEventListener('DOMContentLoaded', Rainbow.color, false);
}

with

document.onreadystatechange = function () {
    if ( document.readyState === "complete" ) {
        Rainbow.color();
    }
}

inside the self executing function at the end of js/rainbow.js solved this for me.

@mcguffin

This comment has been minimized.

Show comment
Hide comment
@mcguffin

mcguffin Oct 3, 2014

See pull request #167
Reworked the code above so it would act neutral against other document.onreadystatechange declarations.

mcguffin commented Oct 3, 2014

See pull request #167
Reworked the code above so it would act neutral against other document.onreadystatechange declarations.

@ccampbell

This comment has been minimized.

Show comment
Hide comment
@ccampbell

ccampbell Jul 3, 2016

Owner

Please take a look at my comment on #167. I am going to close this ticket out as well since I don't think there is a really great solution, but I'm open to further discussion.

Owner

ccampbell commented Jul 3, 2016

Please take a look at my comment on #167. I am going to close this ticket out as well since I don't think there is a really great solution, but I'm open to further discussion.

@ccampbell ccampbell closed this Jul 3, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment