Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$(this).dequeue(); vs next();

Tags:

jquery

queue

Is there any difference if I do:

$queue.queue(function(next){
   //...
   next();
}).queue(function(next){
   //...
   next();
});

versus

$queue.queue(function(){
   //...
   $(this).dequeue();
}).queue(function(){
   //...
   $(this).dequeue();
});

Do they do the same thing?

What are the differences and which should I use?

like image 770
Naftali Avatar asked Dec 06 '12 22:12

Naftali


1 Answers

There isn't much difference. next() simply calls .dequeue() with variables held in a closure (source):

var ...,
    next = function () {
        jQuery.dequeue( elem, type );
    };

I'd say to use next() as it just means less you have to do, since it already has what you need for .dequeue() -- the elements and queue name (or type).

like image 159
Jonathan Lonowski Avatar answered Nov 15 '22 23:11

Jonathan Lonowski