Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

have the callback utilize a return value #11

Closed
ghost opened this Issue · 1 comment

1 participant

@ghost

it would be about 1000 times cooler if the callback returned a boolean which was used to indicate whether or not the form submit should take place.

Instead of

if (typeof this.callback === 'function') {
this.callback(this.errors, event);
}
if (this.errors.length > 0) {

do something like

var return_value = true;
if (typeof this.callback === 'function') {
return_value = this.callback(this.errors, event);
}
if (this.errors.length > 0 || return_value === false) {

that would really help when you do various ajax-y type of validation and form submits

@rickharrison

I will think about utilizing a feature like this. In the meantime, you can prevent the form submission yourself by the following:

if (event && event.preventDefault) {
    event.preventDefault();
} else if (event) {
    event.returnValue = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.