【发布时间】:2021-07-15 20:48:28
【问题描述】:
我创建了一个在鼠标悬停时通过addEventDelegate 调用的弹出框。
弹出框有一个绑定到我的模型的文本元素。
片段:
<Popover xmlns="sap.m"
id="myCardPopover"
showHeader="false"
contentWidth="260px"
placement="Bottom">
<Text id="myCardPopoverText" text="{propertyModel>Tooltip}" />
</Popover>
注册浏览器事件:
attachCardPopoverOnMouseover: function () {
var rootHBox = this.byId("myReportCardContent");
rootHBox.addEventDelegate({
onmouseover: function () {
this.timeId = setTimeout(() => that.onOpenCardPopover(this), 600);
},
onmouseout: function () {
clearTimeout(this.timeId) || that.onCloseCardPopover(this);
}
}, rootHBox);
},
事件监听器:
onOpenCardPopover: function (oControl) {
this.oCardTooltipPopover.then(function (oPopover) {
var oContext = oControl.getBindingContext("propertyModel");
oPopover.setBindingContext(oContext);
oPopover.openBy(oControl);
});
},
Popover 本身依赖于从聚合绑定创建的多个控件,并在 onAfterRendering 中创建。
// Fragment required from "sap/ui/core/Fragment"
createCardPopover: function () {
var oView = this.getView();
var oRootHBox = this.byId("myReportCardContent");
if (!this.oCardTooltipPopover) {
this.oCardTooltipPopover = Fragment.load({
id: oView.getId(),
name: "namespace.view.CardPopup"
}).then(function (oPopover) {
oRootHBox.addDependent(oPopover);
return oPopover;
});
}
},
当我将鼠标悬停在我的一个控件上时,我只会得到一个空的弹出框。未显示绑定的文本。
但是,当我在 UI5 调试工具中查找创建的弹出框时,绑定似乎正确,并且文本也显示在那里。
DOM 中文本的<span> 元素也是空的。
【问题讨论】:
标签: sapui5