Home » Jquery » jquery – Angular 8 click is working as javascript onload function

jquery – Angular 8 click is working as javascript onload function

Posted by: admin February 22, 2020 Leave a comment

Questions:

My angular app is loading in an iframe portlet.

In the parent JSP page, I have a form and submit the invisible button, which will open a popup window from an external app.

I am trying to click that button from the angular component.

Click is not working as expected, It’s working like onload. When the page is getting loaded popup is coming automatically.

Html page.

<html>
...
...
<!-- Left nav Menu-->
<div>
<ul>    <li>....</li>
...
<li>
   <a herf="javascript:void(0);" (click)="navigateToParentJspMethod('true')">Contact Us</a>
</li>
 ...
</html>

Component ts file

navigateToParentJspMethod(popupFlg: string){
console.log(popupFlg+' Test');
if(popupFlg==='true'){
    $("#parentPageFrmSubmit", window.parent.document).click();

}

parent Jsp page

<script>
function openContactUsPopUpFromExternalApp(){
.....
document.getElementById("parentPageFrm").submit();
}
</script>
<form name="parentPageFrm" id="parentPageFrm" action="parentPageFrmSubmitAction" method="post" target="openContactUsWin">
<input type="hidden".....>
......
<button type="submit" id="parentPageFrmSubmit" style="display:none" onclick="openContactUsPopUpFromExternalApp()">Submit</button>
</form>

Thanks,
Rama

How to&Answer: