-1

I want to check something before navigating back and show a fragment where the user cand decide if he really wants to quit the application and go back to the Fiori Launchpad home page, or if he wants to stay in the current application.

I have attached a function to the button

sap.ui.getCore().byId("homeBtn").attachPress(function(){
....
});

and in this function the fragment dialog is opened (which I can only see while debugging), but this doesn't stop the navigation back to the home page.

Does anyone have any idea how I can stop this navigation to the home page, after clicking on the Home Button of the Fiori Launchpad?

Ashish Patil
  • 1,624
  • 2
  • 11
  • 27
  • good post, would also be interested in it. Currently I did not find a way to prevent the home-button Navigation. Anyone able to help? – dotchuZ Sep 20 '16 at 14:15
  • Accessing launchpad controls via `Core.byId` (e.g. `"homeBtn"`) is **not** part of the public APIs! Applications are already breaking because they relied on such solutions: https://answers.sap.com/questions/13627344/ – Boghyon Hoffmann Apr 23 '22 at 13:56

1 Answers1

-1

Use preventdefault to stop navigating to fiori launchpad in click handler of a (anchor) tag which you can find by getting respective DOM element of home button.

If this method is called, the default action of the event will not be triggered.

onAfterRendering: function() {

    var homeBtn = sap.ui.getCore().byId("homeBtn").getDomRef();

    $($(homeBtn).find("a")).on("click", function(event) {
        // do this if user do not want to navigate to launchpad
        event.preventDefault();
    });
}
Ashish Patil
  • 1,624
  • 2
  • 11
  • 27