Need to run helloWorld() after execution of dragTrack() function. But helloWorld is not being called after dragTrack.
dragTrack(function(){
helloWorld();
});
function dragTrack() {
alert('first');
}
function helloWorld() {
alert('second');
}
asked Jan 11, 2016 at 6:50
Kunwarbir S.
2811 gold badge3 silver badges13 bronze badges
-
dragTrack accepts no parameters ?Frebin Francis– Frebin Francis2016年01月11日 06:53:08 +00:00Commented Jan 11, 2016 at 6:53
-
You should first research and than ask questions ,,, refer these answers stackoverflow.com/questions/18514504/…Amar Singh– Amar Singh2016年01月11日 07:04:35 +00:00Commented Jan 11, 2016 at 7:04
2 Answers 2
You are passing a function as argument, but dragTrack need to be changed to accept the callback and to invoke it
dragTrack(helloWorld);
function dragTrack(callback) {
alert('first');
if (callback) {
callback();
}
}
function helloWorld() {
alert('second');
}
answered Jan 11, 2016 at 6:53
Arun P Johny
389k68 gold badges533 silver badges532 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
You are passing helloWorld() as an argument in your dragTrack() call, but you aren't processing it. Your dragTrack function needs a callback Parameter, so you can use your helloWorld() function as an Argument.
Comments
lang-js