Lines 1-35
Link Here
|
1 |
$(document).ready(function () { |
1 |
export function submit_form(form) { |
2 |
$(".submit-form-link").click(function (e) { |
2 |
let form_data = $(form).data(); |
3 |
e.preventDefault(); |
|
|
4 |
let form_data = $(this).data(); |
5 |
|
3 |
|
6 |
let confirm_msg = form_data.confirmationMsg; |
4 |
let confirm_msg = form_data.confirmationMsg; |
7 |
if (confirm_msg) { |
5 |
if (confirm_msg) { |
8 |
let confirmation = confirm(confirm_msg); |
6 |
let confirmation = confirm(confirm_msg); |
9 |
if (!confirmation) { |
7 |
if (!confirmation) { |
10 |
return false; |
8 |
return false; |
11 |
} |
|
|
12 |
delete form_data.confirmationMsg; |
13 |
} |
9 |
} |
|
|
10 |
delete form_data.confirmationMsg; |
11 |
} |
14 |
|
12 |
|
15 |
let the_form = $("<form/>"); |
13 |
let the_form = $("<form/>"); |
16 |
if (form_data.method === "post") { |
14 |
if (form_data.method === "post") { |
17 |
form_data.csrf_token = $('meta[name="csrf-token"]').attr("content"); |
15 |
form_data.csrf_token = $('meta[name="csrf-token"]').attr("content"); |
18 |
} |
16 |
} |
19 |
the_form.attr("method", form_data.method); |
17 |
the_form.attr("method", form_data.method); |
20 |
the_form.attr("action", form_data.action); |
18 |
the_form.attr("action", form_data.action); |
21 |
delete form_data.method; |
19 |
delete form_data.method; |
22 |
delete form_data.action; |
20 |
delete form_data.action; |
23 |
$.each(form_data, function (key, value) { |
21 |
$.each(form_data, function (key, value) { |
24 |
the_form.append( |
22 |
the_form.append( |
25 |
$("<input/>", { |
23 |
$("<input/>", { |
26 |
type: "hidden", |
24 |
type: "hidden", |
27 |
name: key, |
25 |
name: key, |
28 |
value: value, |
26 |
value: value, |
29 |
}) |
27 |
}) |
30 |
); |
28 |
); |
31 |
}); |
|
|
32 |
$("body").append(the_form); |
33 |
the_form.submit(); |
34 |
}); |
29 |
}); |
35 |
}); |
30 |
if (form_data.new_tab) { |
|
|
31 |
the_form.attr("target", "_blank"); |
32 |
} |
33 |
$("body").append(the_form); |
34 |
the_form.submit(); |
35 |
} |
36 |
- |
|
|