I'm trying to execute a JavaScript when a APEX 5.1 modal page is loaded and it's HTML is added to the DOM. The problem with adding the JavaScript to the "Execute when Page Loads" section is that the HTML isn't added to the DOM at that time.
For example I select an iframe element with jQuery $('iframe') and the code is placed in "Execute when Page Loads" and I'm getting that there is no such element in the DOM, but after that I try running this JavaScript and jQuery finds it.
How can I catch the event when the modal page is loaded and it's HTML is added to the DOM?