admin管理员组

文章数量:1334133

I need to retrieve some data attached to a standardListItem when it is dragged. I am handling the drag with jQuery-UI draggable. I did the following:

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");
});

but the data retrieve only works when the StandardListItem is clicked, I doesn't work when the element is dragged. So, the idea is to attach the data retrieve upon mouseenter, how to attach an event listener the mouseenter event.

I need to retrieve some data attached to a standardListItem when it is dragged. I am handling the drag with jQuery-UI draggable. I did the following:

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");
});

but the data retrieve only works when the StandardListItem is clicked, I doesn't work when the element is dragged. So, the idea is to attach the data retrieve upon mouseenter, how to attach an event listener the mouseenter event.

Share Improve this question edited Jan 8, 2021 at 22:04 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Oct 10, 2013 at 12:03 Mohamed Ali JAMAOUIMohamed Ali JAMAOUI 14.7k14 gold badges78 silver badges123 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

You can attach browser event to any of the controls as given below.

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

there is a function called attachBrowserEvent available on every object inheriting from sap.ui.core.Control: https://openui5.hana.ondemand./#docs/api/symbols/sap.ui.core.Control.html#attachBrowserEvent

Using that function you can basically bind to any native event the browser provides.

BR Chris

本文标签: javascriptHow to attach a mouseenter event listener to sapmStandardListItemStack Overflow