A
A
artegion2018-07-02 06:23:33
JavaScript
artegion, 2018-07-02 06:23:33

Wordpress, Contact Form 7. How to correctly write Javascript to call popup after clicking on the Submit button?

Help! Need help setting up a template in WP. There is a window that should open after an action is performed, namely submitting the form, the "Submit" button in Contact Form 7.
The window itself has the following content:

<div class="popup js-popup form-answer" data-modal="form-answer">...</div>

The window can be easily opened by a direct link:
<a href="#" class="js-popup form-answer" data-target="form-answer" >Открыть окно</a>

Now the question is how to force the form to open after the action is completed, after the successful submission of the form, what needs to be written in function.php ??? It is clear that on_sent_ok: is no longer supported.
add_action( 'wp_footer', 'mycustom_wp_footer' );
 
function mycustom_wp_footer() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
    if ( '10' == event.detail.contactFormId ) {
        ???????????????????????????????????????????????????????????????????????????
    }
}, false );
</script>
<?php
}

Thank you for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
ljutaev, 2018-07-02
@artegion

document.addEventListener( 'wpcf7mailsent', function( event ) {
    if ( '10' == event.detail.contactFormId ) {
        $('a.js-popup.form-answer').trigger('click');
    }
}, false );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question