Close and save Lightbox from embedded iframe

Hello,

I have an area in my lightbox that has two buttons. When a user clicks the button I want the scheduled event to save, then close the lightbox and send an email.

Here is my custom code:

    scheduler.form_blocks["my_editor"]={
        render:function(sns){
            return "<iframe border='0' width='100%' height='150' id='dispatch_iframe'></iframe>";
        },
        set_value:function(node,value,ev){
            $('dispatch_iframe').src = "job_details.php?JobID="+ev.PWPJobs_ID+"&ScheduledJobID="+ev.id+"&PWPScheduledJobStatuses_ID="+ev.PWPScheduledJobStatuses_ID;
        },
        // called when SAVING the form
        get_value:function(node,ev){
            var innerDoc = $('dispatch_iframe').contentDocument || $('dispatch_iframe').contentWindow.document;

            if ( innerDoc.getElementById('PWPScheduledJobStatuses_ID') ) {
                return innerDoc.getElementById('PWPScheduledJobStatuses_ID').value;
            }
            else {
                return '4'; //To Be Scheduled
            }
            
            
        }
    };

The iframe itself has three buttons and some text. Here is an example of one of the buttons

                <form method='post' action='/schedule/dispatch_job.pgm.php?ScheduledJobID={!$ScheduledJobID}'>
                    <input class="button" type='submit' value='Dispatch' onclick='return confirm("Are you sure you want to dispatch this job?")'>
                </form>

It does some stuff to change the values for the object and then sends it back to the iframe to change the display. Instead of doing that, I want the lightbox to save the whole task so an email can be sent with the most updated contents.

Any pointers would be greatly appreciated!

Thanks,
Jessica

You can change the buttons code as

It will trigger data saving functionality of scheduler in the parent frame.
As for email sending - it need to be processed on the server side as part of scheduler’s data saving.