How to focus on input field after navigating back from a child page?
Child Page
onNavigateBtnClick: function() {
var oHistory = History.getInstance();
var sPreviousHash = oHistory.getPreviousHash();
if (sPreviousHash !== undefined) {
history.go(-1);
} else {
var bReplace = true;
this.getRouter().navTo("HomePage", {}, bReplace);
}
},
Parent Page
onAfterRendering: function() {
jQuery.sap.delayedCall(500, this, function() {
this.getView().byId("InputField").focus();
});
},
Problem
- When the nav back button is clicked first time, the
onAfterRendering
hook is called. - If I do some action on child page then click on the nav back button, the
onAfterRendering
method would not be called.