Running bug jQuery

Asked

Viewed 136 times

4

I’m having a really weird little problem, I’ve never run into him before.

...

function resizeResponsivo() {
    var 
    width = window.innerWidth,
    height = window.innerHeight;

    if ( width < 651 && keys[0]) {
        keys[0] = false;
        keys[2] = true;
        //
        $(menuBlockB).css('float','left');
        resizeResponsivo(); 
    //
    } else if (width < 493 && keys[1]) {
        keys[1] = false;
        keys[3] = true;
        //
        $(forumBoxLast).hide(function() {

...

When the user enters the site, I run the function to adjust the template on the page, it performs the first condition, in the second it stops, but if I put an Alert(); in both functions it performs normally. Example:

if ( width < 651 && keys[0]) {
    alert();
...
else if ( width < 493 && keys[1] ) {
    alert();

How can I make it right?

Content solved, put the function inside a setTimeout() and worked :)

  • It must have been a deadlock even... with the asynchronous call that doesn’t happen.

2 answers

0

I believe a problem that must be solved first are the global variables as menuBlockB. You have to check how you test your jQuery onload. Also checks the order your files are running.

But I believe it can be a problem turned to onload.

-1

Playing its function to post execution document.ready(function(){}) would solve the problem since the DOM . window functions have already been loaded with the screen parameters.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.