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

Accepted Solutions (1)

Accepted Solutions (1)

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

Answers (2)

Answers (2)

former_member225463
Participant
0 Kudos

Hello Jonny,

Where you have written this code?

the declaration part of columnlistitem is written  in View or Controller?

Regards,

Vikash

Former Member
0 Kudos

move press function logic  to controller like press: [ oController.handlePress , oController ] ,

or

try changing this.onSelectionChange(oEvent); to this.getController().onSelectionChange(oEvent);