Skip to Content
-1

Cannot read property 'navTo' of undefined

Apr 20, 2017 at 05:53 PM

319

avatar image

I am trying do a navigation button in my sapui5 aplication deployed on Fiori

_onPageNavButtonPress: function () {
        var oHistory = History.getInstance();
        var sPreviousHash = oHistory.getPreviousHash();

        if (sPreviousHash !== undefined) {
            window.history.go(-1);
        } else {
            var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
            oRouter.navTo("default", true);
        }

    },


But when I click in the nave button in the console show Cannot read property 'navTo' of undefined

10 |10000 characters needed characters left characters exceeded

Can you attach the routes present in manifest.json file

0

I don't have a json file

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Rubens Pereira Apr 24, 2017 at 07:13 PM
0

I solved it.

Below is my new code

onInit: function(){
			  var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
			},
			
			onBack: function(){
			var oHistory = sap.ui.core.routing.History.getInstance();
			var sPreviousHash = oHistory.getPreviousHash();
			window.history.go(-1);
			},
Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Apr 20, 2017 at 07:15 PM
0

show me the code where you call _onPageNavButtonPress.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

<m:Page id="sap_Responsive_Page_0" showHeader="true" title="Transf" showFooter="true" showNavButton="true" navButtonPress="_onPageNavButtonPress">

0

do you have component.js?

did u initialize the router?

0