I'm currently coding up an application that will have one view come up and then upon its completion will have another view come up. My current code looks something like this:
Controller.startMove("view1", true, true);
Controller.startMove("view2", true, true);
StartMove is a function that will take the view and show it while also implementing the functionality of the call. the second and third parameters are flags for other things not pertaining to this issue. My question is this; How do I "wait" for the first function to finish before doing the second? Right now if I have both up, it doesn't know which view to show and goes crazy.
-
you will need to edit the Controller.startMove method to handle callbackSajithNair– SajithNair2014年02月25日 05:00:59 +00:00Commented Feb 25, 2014 at 5:00
1 Answer 1
The typical pattern in JavaScript is to provide a callback function to an asynchronous function call. When the async call is complete then the callback will be executed.
For example:
Controller.startMove("view1", true, true, function() {
Controller.startMove("view2", true, true, function() {
// Done moving here.
}
}