Skip to Content
Sep 27, 2018 at 05:07 PM

Handle the default back button on UI5/Fiori screen


Hi, I am working on a ui5/fiori app, I am trying to show a pop up when when user clicks on the default back button(See attachment). Popup will have two options 'Continue' and 'Cancel'. If user clicks on Continue button then I'd like to navigate to the previous page else if Cancel button is clicked then I want to stay on the same page. I've tried the below code I am able to see pop up(for a second) but the pop doesn't wait till user click on button. It closes immediately and it navigates to the previous page.

sap.ui.getCore().byId("backBtn").attachPress(function() {
var bCompact; = !!this.getView().$().closest(".sapUiSizeCompact").length; MessageBox.warning( "Unsaved changes are lost, do you want to continue?.",
{ actions: ["Continue", sap.m.MessageBox.Action.CANCEL],
styleClass: bCompact ? "sapUiSizeCompact" : "", onClose: function(sAction) {"Action selected: " + sAction); } } );


back.png (54.2 kB)