Reputation: 10230
I have the following snippet of code :
$('#move').click(function () {
$('#block').animate({
'left': '+=50px'
}, 500);
});
function get_fx() {
var store = console.log($(this).queue('fx').length);
return store;
}
function trigger_it(param) {
$(param).trigger('click');
}
call_it = setInterval(function () {
trigger_it('#move')
},
2000);
Now, after the animate function has been run on $('#block')
, I would like the get_fx()
function to return the number of animations still in the queue for $('#block')
, so I have the following line of code, after the animate function :
.call(this , get_fx())
Now this actually seems to work, but let me show you the result I get in the console :
0 // 0 is displayed , which i guess is the correct result .. I am not sure .
TypeError: $(...).animate(...).call is not a function // I get this error , I don't know why .
Now can somebody tell me why am I getting that error and is my call function doing what its suppose to do ?
EDIT:: I don't want to go with the callback option of the animate function instead i want to use the call function on get_fx() .
Upvotes: 2
Views: 135
Reputation: 2700
animate()
function support call back function. You can utilise this. So you can use like this
$('#move').click(function(){
$('#block').animate({ 'left' : '+=50px' } , 500, function(){
get_fx();
});
Upvotes: 1