Reputation: 57256
Why the animate callback is not triggered after queue:false
has been used?
For instance, a callback occurs here.
$("#move").click(function(){
$(".box").animate({
marginLeft: "100px"
},500 , function() {
alert('complete');
console.log('complete');
});
return false;
});
but not with this,
$("#move").click(function(){
$(".box").animate({
marginLeft: "100px"
}, { queue:false, duration:500 } , function() {
alert('complete');
console.log('complete');
});
return false;
});
the link to jsfiddle
Can I have both queue:false
and callback
at the same time?
Upvotes: 2
Views: 1786
Reputation: 3868
That will not work karthikr... the queue will not function anymore. as you mentioned animate is defined as .animate( properties, options ).You need to make the callback a part of the options argument:
$("#move").click(function(){
$(".box").animate({
marginLeft: "100px",
},{queue:false, duration:500, complete:function() {
alert('complete');
console.log('complete');
}//callback function
});//options and animate
return false;
});
Upvotes: 6
Reputation: 99660
The format is wrong:
Checkout this fiddle
The jquery animate is defined as follows: .animate( properties, options )
$("#move").click(function(){
$(".box").animate({
marginLeft: "100px",
queue:false, duration:500 } , 5000, function() {
alert('complete');
console.log('complete');
});
return false;
});
Upvotes: 2