Skip to content

Commit 280e128

Browse files
committed
remove submitBtn field and add isDeleteForm field
1 parent 2cd9d80 commit 280e128

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,8 @@ https://github.com/trco/django-bootstrap-modal-forms
1717
};
1818

1919
var addEventHandlers = function (settings) {
20-
// submitBtn click handler
21-
$(settings.submitBtn).on("click", function (event) {
22-
isFormValid(settings, submitForm);
23-
});
24-
// Support submition on form fields
2520
$(settings.modalForm).on("submit", function (event) {
26-
if (event.originalEvent !== undefined) {
21+
if (event.originalEvent !== undefined && settings.isDeleteForm === false) {
2722
event.preventDefault();
2823
isFormValid(settings, submitForm);
2924
return false;
@@ -35,7 +30,6 @@ https://github.com/trco/django-bootstrap-modal-forms
3530
});
3631
};
3732

38-
3933
// Check if form.is_valid() & either show errors or submit it via callback
4034
var isFormValid = function (settings, callback) {
4135
$.ajax({
@@ -68,12 +62,14 @@ https://github.com/trco/django-bootstrap-modal-forms
6862
$(settings.modalForm).submit();
6963
} else {
7064
var asyncSettingsValid = validateAsyncSettings(settings.asyncSettings);
71-
var asyncSettings = settings.asyncSettings;
72-
65+
7366
if (asyncSettingsValid) {
67+
var asyncSettings = settings.asyncSettings;
68+
// Serialize form data
7469
var formdata = new FormData($(settings.modalForm)[0]);
7570
// Add asyncUpdate and check for it in save method of CreateUpdateAjaxMixin
7671
formdata.append("asyncUpdate", "True");
72+
7773
$.ajax({
7874
type: $(settings.modalForm).attr("method"),
7975
url: $(settings.modalForm).attr("action"),
@@ -156,8 +152,8 @@ https://github.com/trco/django-bootstrap-modal-forms
156152
modalContent: ".modal-content",
157153
modalForm: ".modal-content form",
158154
formURL: null,
155+
isDeleteForm: false,
159156
errorClass: ".invalid",
160-
submitBtn: ".submit-btn",
161157
asyncUpdate: false,
162158
asyncSettings: {
163159
closeOnSubmit: false,

0 commit comments

Comments
 (0)