Skip to Content
0
Oct 31, 2019 at 12:35 PM

How to attach eventhandler to input field in Fiori Elements application

193 Views

Hi,

Does anyone know how to attach an eventhandler to an input field in a way that the eventhandler also works when reopening the objectpage in a Fiori Listreport?

First time I open an Objectpage I attach the onSubmit to an inputfield in within method onAfterRendering:

onBeforeRendering: function (oEvent) { var oView = this.getView(); var oNamens = sap.ui.getCore().byId(oView.getId() + "--com.sap.vocabularies.UI.v1.Identification::namens::Field-input"); if (oNamens || null) { oNamens.attachSuggestionItemSelected(this._onNamensChanged, this); oNamens.attachSubmit(this._onNamensChanged, this); } },

So when I change the value of this inputfield, method _onNamensChanged is called. This works like a charm.

When I close the Objectpage open again, _onRouteDetailMatched is called, so I coded same logic in this method:

_onRouteDetailMatched: function (oEvent) { var oView = this.getView(); var oNamens = sap.ui.getCore().byId(oView.getId() + "--com.sap.vocabularies.UI.v1.Identification::namens::Field-input"); if (oNamens || null) { oNamens.attachSuggestionItemSelected(this._onNamensChanged, this); oNamens.attachSubmit(this._onNamensChanged, this); } },

But this time _onNamensChanged is not called when I change the value in the input field.

I have no idea why. Anyone?

Cheers,

Robert Dokter