on 03-08-2019 6:35 PM
Hi experts,
I add a new view with a navback button. I can navTo this new page, but the navBack button does not work. Could you help me find out where I did wrong? My onNavBack is copied from Demo Kit. Thank you!
Seats.view.xml:
<mvc:View
controllerName="learningui5.seatselection.controller.Seats"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
xmlns:core="sap.ui.core"
xmlns:semantic="sap.m.semantic"
xmlns:form="sap.ui.layout.form">
<semantic:FullscreenPage
id="page"
navButtonPress="onNavBack"
showNavButton="true"
title="Seats">
<semantic:content>
</semantic:content>
</semantic:FullscreenPage>
</mvc:View>
Seats.controller.js:
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/core/routing/History",
"sap/ui/core/UIComponent"
], function (Controller,History,UIComponent) {
"use strict";
return Controller.extend("learningui5.seatselection.controller.Seats", {
onNavBack: function () {
var oHistory = History.getInstance();
var sPreviousHash = oHistory.getPreviousHash();
if (sPreviousHash !== undefined) {
window.history.go(-1);
} else {
var oRouter = UIComponent.getRouterFor(this);
oRouter.navTo("app", {}, true);
}
}
});
});
manifest.json:
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"viewPath": "learningui5.seatselection.view",
"controlId": "app",
"controlAggregation": "pages",
"async": true
},
"routes": [{
"pattern": "seats",
"name": "seats",
"target": "seats"
}, {
"pattern": "app",
"name": "app",
"target": "app"
}],
"targets": {
"seats": {
"viewID": "seats",
"viewName": "Seats",
"viewLevel" : 2
},
"app": {
"viewId": "app",
"viewName": "App"
}
}
}
In your code I dont see this.getRouter.. but anyways try below code to get router..
this.getOwnerComponent().getRouter()
BR
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.