How to attach a mouseenter event listener to sap.m.StandardListItem?

Mohamed Ali JAMAOUI picture Mohamed Ali JAMAOUI · Oct 10, 2013 · Viewed 10.1k times · Source

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.

Answer

Rohit picture Rohit · Feb 18, 2014

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