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
?
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();
});
}