[英]Getting the oData in the event handler of Fiori Launchpad header event
當用戶單擊Fiori Launchpad中的“后退”按鈕時,我想檢查數據是否更改。 我有以下代碼
onAfterRendering: function() {
sap.ui.getCore().byId("backBtn").attachPress(this, function(oEvent) {
oEvent.preventDefault();
});
}
在函數中,我想訪問oData和主控制器的其他變量。 但是,當我按下后退按鈕時,“ this”對象就是標題控件的視圖。
如何獲取頁面內容的視圖以及如何訪問oData和與內容視圖關聯的控制器的其他參數。
為了訪問當前上下文,您必須在特定上下文中調用事件處理函數,因此需要在該函數上進行綁定。
onAfterRendering: function() {
sap.ui.getCore().byId("backBtn").attachPress(this, function(oEvent) {
oEvent.preventDefault();
}.bind(this));
}
如果使用sap.m.Page
是一個選項,則可以使用navButtonPress內置事件:
View.xml
:
<mvc:View xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc">
<Page navButtonPress="onNavBack">
...
Controller.js
:
onNavBack: function(oControlEvent) {
var oController = this;
var oView = this.getView();
}
每次在Fiori Launchpad標頭中按下按鈕時,都會觸發事件監聽器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.