I want to achieve the following: send some data to the server and upon successful execution, dismiss the current view. What I've done so far:
Try to dimiss the current Viewcontroller in the onFinish (fails) Here is my code
function sendTopic() {
var vServerController = mobileController.serverController();
var vJSONRequest = vServerController.createDataRequest();
vJSONRequest.setQueryMethod("createTopic");
vJSONRequest.setOnFinish(finish);
vServerController.addToQueue(vJSONRequest);
}
function finish(vResponse) {
if (vResponse.body().search("200")) {
//we got a 200 back, everything worked!
logger.showMessage("All okay!");
mobileController.activeController().dismissModal();
}
}
Any Ideas?
The activeController
is not defined for callback methods, since the UI could change during the request execution.
Therefore the solutionController
allows to find the controller you want to dismiss, using the findFirstViewController
method.
Try this in your callback method.
function finish(vResponse) {
if (vResponse.body().search("200")) {
//we got a 200 back, everything worked!
logger.showMessage("All okay!");
var vControllerToDismiss = mobileController.solutionController().findFirstViewController(Screens.MyScreenToDismiss);
if (vControllerToDismiss) {
vControllerToDismiss.dismissModal();
} else {
logger.showMessage("Cant find controller named '" + Screens.MyScreenToDismiss + "'.");
}
}
}