Hi,
I am trying to show a messageBox before navigating from a view. If user selects "YES", navigation can continue. I tried the following code. The code gets triggered but I couldn't stop it from leaving. The messageBox didn't show up:
this.getView().addEventDelegate({ onBeforeHide: function(evt) { var bCompact = oController.getOwnerComponent().getContentDensityClass() === "sapUiSizeCompact"; var pMBMessage = oController.getView().getModel("i18n").getResourceBundle().getText("createDtlCancelMssg"); var pMBTitle = oController.getView().getModel("i18n").getResourceBundle().getText("attention"); MessageBox.confirm( pMBMessage, { styleClass: bCompact ? "sapUiSizeCompact" : "", title: pMBTitle, icon: sap.m.MessageBox.Icon.WARNING, actions: [sap.m.MessageBox.Action.YES, sap.m.MessageBox.Action.NO], onClose: function(oAction) { if (oAction === sap.m.MessageBox.Action.YES) { oController._clearView(); oController.navigateToFirstItem(oController); }else{ return false; } } } ); } });
I tried adding "return false;" but it didn't work.