0

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Mohamed Ali JAMAOUI
  • 14,275
  • 14
  • 73
  • 117

2 Answers2

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();
});
Tim Gerlach
  • 3,390
  • 3
  • 20
  • 39
Rohit
  • 31
  • 3
2

there is a function called attachBrowserEvent available on every object inheriting from sap.ui.core.Control: https://openui5.hana.ondemand.com/#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

cschuff
  • 5,502
  • 7
  • 36
  • 52
  • Can I use attachBrowserEvent method writing only in my XML-View? See my Q. http://stackoverflow.com/questions/31245260/attach-browser-event-to-a-control-using-xml-view – padibro Jul 06 '15 at 13:25