How to prevent an Ajax form from submitting in Drupal 8

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












The below code blocks any non-ajax form from submitting.



$(this.form)
.on('submit', function(event)
if (/* Some condition */)
event.preventDefault();

);


In Drupal 8, how can we block an Ajax form from being submitted?



Ajax forms do not trigger a form submit handler and I have not been able to block the click event on an Ajaxified form's submit buttons.



For reference, I am trying to fix Issue #3010084: Form submission finishes before file upload is complete










share|improve this question



























    up vote
    1
    down vote

    favorite












    The below code blocks any non-ajax form from submitting.



    $(this.form)
    .on('submit', function(event)
    if (/* Some condition */)
    event.preventDefault();

    );


    In Drupal 8, how can we block an Ajax form from being submitted?



    Ajax forms do not trigger a form submit handler and I have not been able to block the click event on an Ajaxified form's submit buttons.



    For reference, I am trying to fix Issue #3010084: Form submission finishes before file upload is complete










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      The below code blocks any non-ajax form from submitting.



      $(this.form)
      .on('submit', function(event)
      if (/* Some condition */)
      event.preventDefault();

      );


      In Drupal 8, how can we block an Ajax form from being submitted?



      Ajax forms do not trigger a form submit handler and I have not been able to block the click event on an Ajaxified form's submit buttons.



      For reference, I am trying to fix Issue #3010084: Form submission finishes before file upload is complete










      share|improve this question













      The below code blocks any non-ajax form from submitting.



      $(this.form)
      .on('submit', function(event)
      if (/* Some condition */)
      event.preventDefault();

      );


      In Drupal 8, how can we block an Ajax form from being submitted?



      Ajax forms do not trigger a form submit handler and I have not been able to block the click event on an Ajaxified form's submit buttons.



      For reference, I am trying to fix Issue #3010084: Form submission finishes before file upload is complete







      8 forms ajax webforms






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      jrockowitz

      1,935910




      1,935910




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote













          I found the solution here.



          // Add submit handler to form.beforeSend.
          // Update Drupal.Ajax.prototype.beforeSend only once.
          if (typeof Drupal.Ajax !== 'undefined' && typeof Drupal.Ajax.prototype.beforeSubmitOriginal === 'undefined')
          Drupal.Ajax.prototype.beforeSubmitOriginal = Drupal.Ajax.prototype.beforeSubmit;
          Drupal.Ajax.prototype.beforeSubmit = function (form_values, element_settings, options)
          if (/* Custom condition */)
          this.ajaxing = false;
          return false;

          return this.beforeSubmitOriginal();
          ;






          share|improve this answer




















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "220"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "",
            contentPolicyHtml: "",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdrupal.stackexchange.com%2fquestions%2f271808%2fhow-to-prevent-an-ajax-form-from-submitting-in-drupal-8%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote













            I found the solution here.



            // Add submit handler to form.beforeSend.
            // Update Drupal.Ajax.prototype.beforeSend only once.
            if (typeof Drupal.Ajax !== 'undefined' && typeof Drupal.Ajax.prototype.beforeSubmitOriginal === 'undefined')
            Drupal.Ajax.prototype.beforeSubmitOriginal = Drupal.Ajax.prototype.beforeSubmit;
            Drupal.Ajax.prototype.beforeSubmit = function (form_values, element_settings, options)
            if (/* Custom condition */)
            this.ajaxing = false;
            return false;

            return this.beforeSubmitOriginal();
            ;






            share|improve this answer
























              up vote
              3
              down vote













              I found the solution here.



              // Add submit handler to form.beforeSend.
              // Update Drupal.Ajax.prototype.beforeSend only once.
              if (typeof Drupal.Ajax !== 'undefined' && typeof Drupal.Ajax.prototype.beforeSubmitOriginal === 'undefined')
              Drupal.Ajax.prototype.beforeSubmitOriginal = Drupal.Ajax.prototype.beforeSubmit;
              Drupal.Ajax.prototype.beforeSubmit = function (form_values, element_settings, options)
              if (/* Custom condition */)
              this.ajaxing = false;
              return false;

              return this.beforeSubmitOriginal();
              ;






              share|improve this answer






















                up vote
                3
                down vote










                up vote
                3
                down vote









                I found the solution here.



                // Add submit handler to form.beforeSend.
                // Update Drupal.Ajax.prototype.beforeSend only once.
                if (typeof Drupal.Ajax !== 'undefined' && typeof Drupal.Ajax.prototype.beforeSubmitOriginal === 'undefined')
                Drupal.Ajax.prototype.beforeSubmitOriginal = Drupal.Ajax.prototype.beforeSubmit;
                Drupal.Ajax.prototype.beforeSubmit = function (form_values, element_settings, options)
                if (/* Custom condition */)
                this.ajaxing = false;
                return false;

                return this.beforeSubmitOriginal();
                ;






                share|improve this answer












                I found the solution here.



                // Add submit handler to form.beforeSend.
                // Update Drupal.Ajax.prototype.beforeSend only once.
                if (typeof Drupal.Ajax !== 'undefined' && typeof Drupal.Ajax.prototype.beforeSubmitOriginal === 'undefined')
                Drupal.Ajax.prototype.beforeSubmitOriginal = Drupal.Ajax.prototype.beforeSubmit;
                Drupal.Ajax.prototype.beforeSubmit = function (form_values, element_settings, options)
                if (/* Custom condition */)
                this.ajaxing = false;
                return false;

                return this.beforeSubmitOriginal();
                ;







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 35 mins ago









                jrockowitz

                1,935910




                1,935910



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdrupal.stackexchange.com%2fquestions%2f271808%2fhow-to-prevent-an-ajax-form-from-submitting-in-drupal-8%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery