Reputation: 2169
Even with .promise().done()
my callback function fires early..
Why?
title.delay(1000).show(1200).promise().done( function(){
menu.show(0, function(){
menu.find('*').show(600, message())
})
})
message = function(){ alert('done'); }
Upvotes: 2
Views: 1658
Reputation: 10003
This code:
menu.find('*').show(600, message())
Needs to be:
menu.find('*').show(600, message)
The difference is: in the first example you effectively pass two arguments:
600
message
(which is undefined
here)Because ()
- is the operator to call function in JavaScript.
In the second example, however, you pass 600
and function message
.
As @FakeRainBrigand noted - if you want to supply arguments to the function - you have several ways:
message = message.bind(<context>, param1, param2,...)
. Then any time you call message
it will be called with <context>
as this
and param*
as arguments..show(600, function() {
message(param1, param2, ...);
});
Upvotes: 6