Search code examples
sapui5

select event not fired on the same item


I have a master-detail splitapp use for phone browser. Master page display the main list and when I click on an item, it will navigate to detail page.

The problem is, from detail page, I click on BackArrow to back to master page and tap again on the same item, onSelect event won't fire > no go anywhere. But if I tap on another item, it works.

In manifest.json, master viewlevel = 1 and detail viewlevel = 2.

Thanks

Below is the detail page navigation button

<Page
title="Title text"
showNavButton="true"
navButtonPress="onNavBack">

onNavBack function

onNavBack: function (oEvent) {
  var oHistory = History.getInstance();
  var sPreviousHash = oHistory.getPreviousHash();

  if (sPreviousHash !== undefined) {
      window.history.go(-1);
  } else {
  // no history handle
}}

onSelect to forward

, onSelect : function(oEvent) {
    var oTransferData = this.createTransferData(oContext);
    this.transferData.setData(oTransferData);
...
this.getRouter().navTo(
    "detail", {	ZITEM : oTransferData.ZITEM }
);
}
    
, createTransferData : function(oContext) {
    var oData = {};    
    oData.ZITEM = oContext.getProperty("ZITEM");
}

the list

<List
    id="masterList"
    noDataText="no data"
    mode="SingleSelectMaster"
    selectionChange="onSelect"
    includeItemInSelection="true"
>


Solution

  • Try itemPress event instead of select (make sure item has "Active" in its type property). It fires whenever you click on item, and select only fires when the selection changes.