View | Details | Raw Unified | Return to bug 36246
Collapse All | Expand All

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

Return to bug 36246