cancel
Showing results for 
Search instead for 
Did you mean: 

Call Controller Function from Handler Press Event

Former Member
0 Kudos

Hi,

I have this code:


var oItem = new sap.m.ObjectListItem({

     id: "mainListItem",

     //press: "onSelectionChange",

     press: function(oEvent){

     this.onSelectionChange(oEvent);

     },

     type: "Active",

     title: "{Description}",

     number: "{Activity}",

});

But de application displays this error:

Master.controller.js:47 Uncaught TypeError: this.onSelectionChange is not a function


I used the code press: "onSelectionChange",but display this error:

sap-ui-core.js:143 Uncaught TypeError: I.fFunction.call is not a function

The onSelectionChange method exits in the View controller (BaseController). The application is a template of SAP Fiori Master / Detail 1.28.

Best regards,

Johnny

View Entire Topic
saxos
Explorer

Hi Johnny,

before your initialize your Item, try:

self = this;

and than IN your initialize:

  1. var oItem = new sap.m.ObjectListItem({ 
  2.      id: "mainListItem"
  3.      //press: "onSelectionChange", 
  4.      press: function(oEvent){ 
  5.      self.onSelectionChange(oEvent); 
  6.      }, 
  7.      type: "Active"
  8.      title: "{Description}"
  9.      number: "{Activity}"
  10. });