Useless setTimeout call (missing quotes around argument?)
Asked Answered
N

5

18

I have this sniplet of code in jQuery

$element.parent().children().last().hide().show('slide', {direction : 'left'}, 700, function () {
    $element.delay(2000, function() {
        $element.parent().children().last().hide('slide', {direction: 'left'}, 700);             
        reload_table(question_number);
        //delay ends here
    });
});

delay is declared as:

jQuery.fn.delay = function(time,func){
    return this.each(function(){
        setTimeout(func,time);
    });
};

Now I get the error:

useless setTimeout call (missing quotes around argument?)

FF3.x, Firefox 6+ is ok. Any ideas on that? Why could this be happening?

Nanna answered 21/11, 2011 at 11:25 Comment(0)
N
6

There already exists a jQuery-method delay and it expects a string(queueName) and not a function as parameter. Choose another name for your delay-method to avoid conflicts.

Nidia answered 21/11, 2011 at 11:47 Comment(1)
sorry to say that but that didnt fix itNanna
G
17

I got same error when I wrote

setTimeout(updateStatus(), 5000);

instead of

setTimeout(updateStatus, 5000);
Gord answered 7/12, 2012 at 7:20 Comment(1)
OP is already calling the method correctly! this is not the issue. He is already passing a pointer to a function, in the first argument.Complacence
S
10

I agree with wsbaser. I had the additional instance of needed to pass information to the function, and for simplicity used:

setTimeout(function(){ updateStatus(myData) } , 5000);

The argument needs to be a function and not a function being called. Firefox caught this error, chrome let it go.

Subak answered 1/8, 2013 at 14:9 Comment(0)
S
7

Just for reference if someone stumbles upon this question and is looking for a possible answer. I got the exact same error message as the initial poster because I was mixing up the setTimeout arguments order.

This:

setTimeout(25, function(){
    spotlight.intro.find('#intro').ellipsis();  
});

... gave me the error message. I changed the function to this:

setTimeout(function(){
    spotlight.intro.find('#intro').ellipsis();
}, 25);

And my problem was solved.

Sanctified answered 24/7, 2012 at 13:44 Comment(0)
N
6

There already exists a jQuery-method delay and it expects a string(queueName) and not a function as parameter. Choose another name for your delay-method to avoid conflicts.

Nidia answered 21/11, 2011 at 11:47 Comment(1)
sorry to say that but that didnt fix itNanna
N
-1

The problem was in Firefox 3. It is not handling some elements properly => Element is completely omitted in the tree and ignored -> hence my original problem

Nanna answered 23/11, 2011 at 9:23 Comment(1)
Very unhelpful and undescriptive answer.Georgie

© 2022 - 2024 — McMap. All rights reserved.