Skip to content

Commit 2cd9d80

Browse files
authored
Merge pull request #133 from virdiignis/patch-1
Fix submitting the form using Enter key.
2 parents 67ad654 + 631cd2b commit 2cd9d80

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bootstrap_modal_forms/static/js/jquery.bootstrap.modal.forms.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ https://github.com/trco/django-bootstrap-modal-forms
2121
$(settings.submitBtn).on("click", function (event) {
2222
isFormValid(settings, submitForm);
2323
});
24+
// Support submition on form fields
25+
$(settings.modalForm).on("submit", function (event) {
26+
if (event.originalEvent !== undefined) {
27+
event.preventDefault();
28+
isFormValid(settings, submitForm);
29+
return false;
30+
}
31+
});
2432
// Modal close handler
2533
$(settings.modalID).on("hidden.bs.modal", function (event) {
2634
$(settings.modalForm).remove();
@@ -175,4 +183,4 @@ https://github.com/trco/django-bootstrap-modal-forms
175183
return this;
176184
};
177185

178-
}(jQuery));
186+
}(jQuery));

0 commit comments

Comments
 (0)