frayerjj-frontend 0.8.20 → 0.8.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/init.js +22 -1
package/package.json
CHANGED
package/src/init.js
CHANGED
|
@@ -106,7 +106,28 @@ export const init = (args) => {
|
|
|
106
106
|
modal.confirm(
|
|
107
107
|
el.getAttribute('confirm-msg') || 'Are you sure?',
|
|
108
108
|
() => {
|
|
109
|
-
|
|
109
|
+
const href = el.getAttribute('href');
|
|
110
|
+
if (el.classList.contains('delete-link')) {
|
|
111
|
+
const form = document.createElement('form');
|
|
112
|
+
form.method = 'POST';
|
|
113
|
+
form.action = href;
|
|
114
|
+
const methodInput = document.createElement('input');
|
|
115
|
+
methodInput.type = 'hidden';
|
|
116
|
+
methodInput.name = '_method';
|
|
117
|
+
methodInput.value = 'DELETE';
|
|
118
|
+
form.appendChild(methodInput);
|
|
119
|
+
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
|
|
120
|
+
if (csrfToken) {
|
|
121
|
+
const csrfInput = document.createElement('input');
|
|
122
|
+
csrfInput.type = 'hidden';
|
|
123
|
+
csrfInput.name = 'csrfmiddlewaretoken';
|
|
124
|
+
csrfInput.value = csrfToken;
|
|
125
|
+
form.appendChild(csrfInput);
|
|
126
|
+
}
|
|
127
|
+
document.body.appendChild(form);
|
|
128
|
+
form.submit();
|
|
129
|
+
} else
|
|
130
|
+
location.href = href;
|
|
110
131
|
},
|
|
111
132
|
() => {},
|
|
112
133
|
el.getAttribute('confirm-title') || 'Confirm',
|