我有一个带有详细页面的SAPUI5 splitapp。此详细信息页面包含ObjectListItem
的列表。我想听一下这个项目的新闻/选择,但我总是要按两次元素,否则事件不会被触发。
有人知道是什么原因吗?
谢谢和最好的问候
详细信息XML
<Page
id="myJobsPage"
title="{i18n>myJobsTitle}">
<List
id="myJobsMasterList"
inset="false"
items="{testkunden}">
<ObjectListItem
id="myJobsListItem"
visible="true"
title="{job}"
number="{offen}"
numberUnit="Euro"
press="onMyJobsListItem"
type="Active">
<!-- visible part -->
<ObjectAttribute
id="Gpart123"
text="Partner: {gpart}"
visible="true" />
<ObjectAttribute
id="Anrede123"
text="{anrede}"
visible="true" />
<ObjectAttribute
id="Name123"
text="{vorname} {nachname}"
visible="true" />
<ObjectAttribute
id="Strasse123"
text="{strasse} {hausnr}"
visible="true" />
</ObjectListItem>
<!-- <ObjectStatus text="{i18n>myJobsObjectStatus}" /> -->
</List>
</Page>
</mvc:View>
控制器
onMyJobsListItem: function(event){
console.log("only triggers if click twice");
};
更新 Splitapp Root View
<mvc:View
controllerName="mobile.splitapp.controller.App"
displayBlock="true"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" >
<App id="app">
<SplitApp id="splitapp" >
<masterPages>
<mvc:XMLView viewName="mobile.splitapp.view.Master" id="master1" />
</masterPages>
<detailPages>
<mvc:XMLView viewName="mobile.splitapp.view.MyJobs" id="myJobsPage" />
<mvc:XMLView viewName="mobile.splitapp.view.DisconnectionOrder" id="disconnectionOrderPage" />
</detailPages>
</SplitApp>
</App>
</mvc:View>
答案 0 :(得分:0)
以下是您的代码的运行示例(请参阅下面的jsbin和updated jsbin),它运行得很好!由于你没有发布你的“周围”代码,我无法分辨出什么是错的。但正如您在下面的示例中所看到的,事件在第一次按下后直接触发......
您能否发现代码存在差异?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>SAPUI5 single file template | nabisoft</title>
<script src="https://openui5beta.hana.ondemand.com/resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.m"
data-sap-ui-bindingSyntax="complex"
data-sap-ui-compatVersion="edge"
data-sap-ui-preload="async"></script>
<!-- use "sync" or change the code below if you have issues -->
<!-- XMLView -->
<script id="myXmlView" type="ui5/xmlview">
<mvc:View
controllerName="MyController"
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc">
<App>
<SplitApp>
<masterPages>
<Page
id="myJobsPage"
title="Master Page">
<List
id="myJobsMasterList"
inset="false"
items="{/Customers}">
<ObjectListItem
id="myJobsListItem"
visible="true"
title="{CompanyName}"
number="{offen}"
numberUnit="Euro"
press="onMyJobsListItem"
type="Active"/>
</List>
</Page>
</masterPages>
<detailPages>
<Page
title="Detail Page">
<List
inset="false"
items="{/Customers}">
<ObjectListItem
visible="true"
title="{CompanyName}"
number="{offen}"
numberUnit="Euro"
press="onMyJobsListItem"
type="Active"/>
</List>
</Page>
</detailPages>
</SplitApp>
</App>
</mvc:View>
</script>
<script>
sap.ui.getCore().attachInit(function () {
"use strict";
//### Controller ###
sap.ui.controller("MyController", {
onInit : function () {
this.getView().setModel(
new sap.ui.model.odata.v2.ODataModel("https://cors-anywhere.herokuapp.com/services.odata.org/V2/Northwind/Northwind.svc/", {
json : true,
useBatch : false
})
);
},
onMyJobsListItem: function(event){
alert("press");
}
});
//### THE APP: place the XMLView somewhere into DOM ###
sap.ui.xmlview({
viewContent : jQuery("#myXmlView").html()
}).placeAt("content");
});
</script>
</head>
<body class="sapUiBody">
<div id="content"></div>
</body>
</html>