Call function and variables from dialog's parent app

Hello,

I'm making a custom dialog component following the prompt demo that's in: https://ej2.syncfusion.com/16.1.32/angular/demos/#/material/dialog/basic.

I need to call two different methods in sequence when I click on the “Confirm” button from the dialog window. Both of these methods are defined in the parent app. The first method runs without problems when it's directely called by the button object's click event, but the second one get's an error saying that that method isn't a function when it is. The second one is called right after the first method is done.

Fusing both methods didn't work because the second one needs information that's stored in a varaible from the parent app. When I tried to run that single method I got an error saying that the variable that I was calling is 'undefined'.

It's like the dialog prompt can't see the parent app's methods and variables besides the ones that are linked to the buttons events.

My question is, does the dialog component have an equivalent method to “window.opener.foo()” that's present in javascript? I tried doing “this.opener.foo()” inside the method that works but that didn't work either.

Thanks for the help!


3 Replies

NP Narayanasamy Panneer Selvam Syncfusion Team April 17, 2018 01:02 PM UTC

Hi Alberto, 
 
Thanks for using Syncfusion products. 
 
We have validated your queries. We have to bind “this” element to click event of button to access parent app’s methods like this.alertDlgBtnClick.bind(this). While perform dialog’s button click event inside the corresponding function, “this” will be considered as instance of corresponding dialog. 
We have achieved your requirement in the below sample. When click on alert dialog’s button, the prompt dialogs’ content will be updated.  
Please find it in the below link: https://plnkr.co/edit/wTM9c8eHG8AkyA4iRCe6?p=preview  
 
Regards,
Narayanasamy P 



AV Alberto Vázquez April 17, 2018 02:21 PM UTC

Works like a charm.

Thanks a lot!


NP Narayanasamy Panneer Selvam Syncfusion Team April 18, 2018 04:05 AM UTC

Hi Alberto, 
 
Thanks for your update. 

We are glad to hear that your issue has resolved. Please let us know if you need further assistance.

 
Regards, 
Narayanasamy p. 


Loader.
Up arrow icon