Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery transfer effect & callback function

I want to know if the jQuery transfer effect has any callback mechanism by which I can determine when a transfer effect starts and when ends. I got the code below, but I found no callback function…

Please help. Thanks.

$("div").click(function () {
  var i = 1 - $("div").index(this);
  $(this).effect("transfer", { to: $("div").eq(i) }, 1000);
});
like image 510
Keith Costa Avatar asked Oct 25 '11 13:10

Keith Costa


2 Answers

Assuming you're talking about jQuery UI's effect method, then it takes a callback function as an argument. That callback will run when the effect has completed:

$(this).effect("transfer", { to: $("div").eq(i) }, 1000, function() {
    //Done!
});

As for when the effect starts, the lines following the call to effect should be run immediately after the call (so before the effect is complete).

like image 89
James Allardice Avatar answered Nov 06 '22 05:11

James Allardice


The documentation for the "Transfer effect" does not state so, but the documentation for effect does state that a callback can be specified. Obviously this is the completion callback.

effect( effect, [options], [speed], [callback] )

As for when it starts, you must assume that is "immediately".

like image 2
Grant Thomas Avatar answered Nov 06 '22 05:11

Grant Thomas