Create a return button
In this task, you learn how to use the navButtonPress
event to navigate back to the previous page.
Procedure
-
On the application tree, click
PageAddContact
. -
In the properties pane, go to Properties > showNavButton and change it to
true
. -
Go to Events > navButtonPress and click .
Result: On the preview pane, the JavaScript Editor opens.
-
In the JavaScript Editor, right-click and select SAPUI5 > Other > Navigation sap.m.
Result: A number of code snippets are added to the editor.
-
Leave only one snippet and delete the rest:
// Go to a new page // Replace App to your App component and replace newPage to the new Page oApp.to(nextPage);
-
Replace
oApp
withApp
andnextPage
withPageAddContact
. -
Click Save and Activate.
Results
-
You have created a button to navigate back to the previous page.
-
The button is displayed on the shell bar of your application.
To preview your application, see Preview your application.