cancel
Showing results for 
Search instead for 
Did you mean: 

Function call from other controller with passing information about this.getView()

0 Kudos

In my MainController I'd like to call a function from my ManualUploadController by pushing a button

The function call itself is working fine like this:

var oManualUploadController = new ManualUpload();
var backendData = oManualUploadController.onGenerateBackendData();

However, in the "onGenerateBackendData()" method, I retrieve models for example like this:

var oModel = this.getView().getModel('odataDetails');

What's funny is:

The ManualUploadController creates a Dialog with some logic in it and the MainController is the "mainpage" from where the dialog gets opened.

When initially accessing the mainpage and trying to push/execute that funciton, I get the error"Uncaught TypeError: Cannot read property 'getModel' of undefined".

But when the Dialog has already been opened previously, then closed again and then the button on the mainpage gets pushed, the function call works fine without any errors.

Do I have to instantiate the controller somehow or how can I solve this problem?

I really hope, I managed to explain my problem so that you understand it. Please let me know if I should try again!

Thanks!

Accepted Solutions (0)

Answers (1)

Answers (1)

ericci
Active Contributor
0 Kudos

Have you used the addDependent when you create the dialog? That could be a good reason 😉