Javascript 如何将mouseenter事件侦听器附加到sap.m.StandardListItem?

Javascript 如何将mouseenter事件侦听器附加到sap.m.StandardListItem?,javascript,dom-events,sapui5,attachevent,Javascript,Dom Events,Sapui5,Attachevent,我需要在拖动standardListItem时检索附加到它的一些数据。我正在使用jQuery UI Dragable处理拖动。我做了以下工作: var oItemTemplate = new sap.m.StandardListItem(); oItemTemplate .bindProperty("title", "ListModel>oLabel"); oItemTemplate .data("usefulListData",

我需要在拖动
standardListItem
时检索附加到它的一些数据。我正在使用jQuery UI Dragable处理拖动。我做了以下工作:

var oItemTemplate = new sap.m.StandardListItem();
oItemTemplate .bindProperty("title", "ListModel>oLabel");
oItemTemplate .data("usefulListData","ListModel>EdmType");
oItemTemplate .addStyleClass("Draggable");
oItemTemplate .setType(sap.m.ListType.Active);
oItemTemplate .attachPress(function( ){
console.log(this.data("usefulListData"));
console.log("item pressed");
});

但是数据检索只在单击
StandardListItem
时起作用,而在拖动元素时我不起作用。因此,我们的想法是在
mouseenter
时附加数据检索,如何将事件侦听器附加到
mouseenter
事件。

从sap.ui.core.Control继承的每个对象上都有一个名为attachBrowserEvent的函数:

使用该函数,您基本上可以绑定到浏览器提供的任何本机事件


Chris

从sap.ui.core.Control继承的每个对象上都有一个名为attachBrowserEvent的函数:

使用该函数,您基本上可以绑定到浏览器提供的任何本机事件


Chris

您可以将浏览器事件附加到任何控件,如下所示

oItemTemplate.attachBrowserEvent("mouseenter", function(oEvent) {
    //get your model and do whatever you want:
    oModel = sap.ui.getCore().getModel();
});

您可以将浏览器事件附加到任何控件,如下所示

oItemTemplate.attachBrowserEvent("mouseenter", function(oEvent) {
    //get your model and do whatever you want:
    oModel = sap.ui.getCore().getModel();
});

我可以只在XML视图中使用attachBrowserEvent方法吗?请参阅我的问题。是否可以仅在XML视图中使用attachBrowserEvent方法编写?见我的问题。