asked on July 6, 2022 Show version history

Hello, I am using a series of iframes and using z-index to layer behind an initial form (these iframes would represent different forms from separate processes that are ultimately going to be used when someone is doing something as part of a package (which could involve multiple processes);  We need to avoid the need for multiple starting events since this is not possible with forms as far as we know.  

 

My idea for the solution that I haven't been able to get working was to use the iframes and z-index to layer so that user would only see one iframe but the ultimate goal would be to trigger all of the save-to-drafts on all of the iframes once they are fully loaded.  What is weird is that I can't get the save-to-draft button to trigger (only time I have been successful was when I used chrome dev tools and instead of .draft-btn, I had to use $('.btn-wrapper').children().eq(1).click();

 

If anyone is able to help get this working with even just one iframe, I would appreciate it.  

 

Edit:  After playing with this some more, this is the code I have come up with - it detects when the iframe is loaded, consoles out the correct button, but no matter what, I am not able to trigger it with js (although I am able to set an event listener on click of this button and have it alert me when button is clicked, which is not what I need since I need this to happen dynamically without any user interaction)

 

            $('#iframe1').load(function(){
                 //alert('content has been loaded');
                 var iframe = $('#iframe1').contents();
                 //console.log(iframe);
                 var targetButton = iframe.find(".draft-btn");
                 //console.log(targetButton);
                 targetButton.click();
             });

0 0