cancel
Showing results for 
Search instead for 
Did you mean: 

Navigate to a route pattern on refresh

ranjit_rao
Participant
0 Kudos

HI Experts,

I am using routing in my SAPUI5 application. I have a requirement where when the user presses refresh(F5) button, the Home View should appear.

Can some one help?

Thanks in advance.

Ranjit

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member227918
Active Contributor
0 Kudos

Hello Ranjit,

here is a workaround i have tried in SAPUI5 version 1.28.3 and 1.38.3, you can write below line inside init function of component file after initialize the router.(we can find more appropriate trigger point also)

this.getRouter().initialize();

$(document.body).on("keydown", this, jQuery.proxy(this._onKeyPress, this));

and function is:

_onKeyPress: function(oEvent) {

    oEvent = oEvent || window.event;

    if (oEvent.keyCode == 116) {

        this.getRouter().navTo("worklist", {}, true);

    }

}

hope this will help you.

Regards,

Akhilesh

ranjit_rao
Participant
0 Kudos

I have tried this but once the navigated screen come, All the links buttons and other clickable controls are no more clickable.

Thanks

Ranjit

former_member227918
Active Contributor
0 Kudos

it should work, for me its working fine.

can u check errors in console if any and share ui5 version and console errors.

Regards,

Akhilesh

Former Member
0 Kudos

Hi,


window.onbeforeunload = function (e) {
  e
= e || window.event;
  
if (window.event.keyCode == 116) {
  alert
("f5 pressed");
  
}
  
};


jquery - capturing f5 keypress event in javascript using window.event.keyCode in window.onbeforeunlo...


Regards Yalcin

ranjit_rao
Participant
0 Kudos

Thank you for the quick response.

I have tried this, But how to route to a particular view within this?

Former Member
0 Kudos

If you entreance to insedi in if statement,you use router.

ranjit_rao
Participant
0 Kudos

I have tried this but once the navigated screen come, All the links buttons and other clickable controls are no more clickable.