• Resolved elbradey

    (@elbradey)


    Hello dears, thank you for the amazing plugin!

    My form has a lot of fields and conditions which really slows down the submission time, so I was wondering if there is a method to add a loading animation to the submit button using custom CSS or anything else when clicked until the submitting indicator above the form appears, as the user thinks it’s frozen while it’s processing.

    Thanks in advance!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @elbradey

    I hope you are doing well.

    Sorry to hear you are having this slow submission, we are working on a feature that allows adding conditional to sections so instead of multiple conditionals you will be able to apply to that specific section and it will speed up the submissions too.

    Unfortunately only a CSS solution is not possible, Forminator does have a BeforeSend event https://api.jquery.com/jquery.ajax/ and it allows us to add some action for example insert a class or trigger an event, you can test something like:

    <?php
    
    add_action( 'wp_footer', function(){ ?>
    <script>
    	(function ($) {
    		$(function () {
    			$(document).on("before:forminator:form:submit", function (e, draftData) {
                    alert('submitting');
                    $("<div>Submitting</div>").insertBefore(".forminator-button-submit");
    			});
    		});
    	})(window.jQuery);
    </script>
    <?php }, 21); ?>

    As a mu-plugin https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins but it also depends on the time that the Ajax request reaches this beforeSend moment.

    Let us know if this helps you.
    Best Regards
    Patrick Freitas

    Thread Starter elbradey

    (@elbradey)

    Thank you Patric for your help!
    The next features will be amazing actually! Can’t wait to see it.

    I tested the MU Plugin you’ve provided, it might be not convenient because it appears right before the “beforeSend” moment.
    It’s been processing for some time.

    The point is the “onClick” to Submit Button, not “beforeSend”. Not sure if it exists or not but I think you understand my issue here.

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @elbradey

    I hope you are doing well.

    You can use the jQuery Click:

    jQuery( ".forminator-button-submit").click(function() {
      alert( "Handler for .click() called." );
    });

    https://api.jquery.com/click/

    <?php
    
    add_action( 'wp_footer', function(){ ?>
    <script>
    	(function ($) {
    		$(function () {
    			$(document).on("after.load.forminator", function (e, id) {
    
                    // Ajax forms
                    $( ".forminator-button-submit").click(function(){
                        $("<div>Submitting</div>").insertBefore(".forminator-button-submit");
                    });
    
    			});
    
                // Non Ajax Form
                $( ".forminator-button-submit").click(function(){
                    $("<div>Submitting</div>").insertBefore(".forminator-button-submit");
                });
    
    		});
    	})(window.jQuery);
    </script>
    <?php }, 21); ?>

    This is only an example of code, you would need to extend it to add a Div or any CSS using JS.

    Best Regards
    Patrick Freitas

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @elbradey ,

    We haven’t heard from you for some time now, so it looks like you don’t have any more questions for us.

    Feel free to re-open this ticket if needed.

    Kind regards
    Kasia

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Adding loading animation to submit button’ is closed to new replies.