Skip to content

Commit 36e1597

Browse files
author
aDramaQueen
committed
Updated JavaScript
Added documentation. Added new property for settings: credentials.
1 parent 209a3eb commit 36e1597

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bootstrap_modal_forms/static/js/bootstrap5.modal.forms.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const modalFormCallback = function (settings) {
2121
})
2222
}
2323

24-
fetch(settings.formURL).then(res => {
24+
fetch(settings.formURL, {credentials: settings.credentials}).then(res => {
2525
// Get content from target URL
2626
return res.text();
2727
}).then(data => {
@@ -131,6 +131,7 @@ const submitForm = function (settings) {
131131
fetch(form.action, {
132132
method: form.method,
133133
body: formData,
134+
credentials: settings.credentials,
134135
}).then(res => {
135136
return res.text();
136137
}).then(data => {
@@ -145,7 +146,7 @@ const submitForm = function (settings) {
145146

146147
if (asyncSettings.dataUrl) {
147148
// Update page without refresh
148-
fetch(asyncSettings.dataUrl).then(res => res.json()).then(data => {
149+
fetch(asyncSettings.dataUrl, {credentials: settings.credentials}).then(res => res.json()).then(data => {
149150
// Update page
150151
let dataElement = document.querySelector(asyncSettings.dataElementId);
151152
if (dataElement) {
@@ -161,7 +162,7 @@ const submitForm = function (settings) {
161162
bootstrap.Modal.getInstance(modal).hide();
162163
} else {
163164
// Reload form
164-
fetch(settings.formURL).then(res => {
165+
fetch(settings.formURL, {credentials: settings.credentials}).then(res => {
165166
return res.text();
166167
}).then(data => {
167168
let content = modal.querySelector(settings.modalContent);

0 commit comments

Comments
 (0)