How to prevent an Ajax form from submitting in Drupal 8
Clash 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
8 forms ajax webforms
add a comment |Â
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
8 forms ajax webforms
add a comment |Â
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
8 forms ajax webforms
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
8 forms ajax webforms
asked 1 hour ago
jrockowitz
1,935910
1,935910
add a comment |Â
add a comment |Â
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();
;
add a comment |Â
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();
;
add a comment |Â
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();
;
add a comment |Â
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();
;
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();
;
answered 35 mins ago
jrockowitz
1,935910
1,935910
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password