Quantcast
Channel: Editor — DataTables forums
Viewing all articles
Browse latest Browse all 3744

Update select options, losing the field when submit

$
0
0

HI,
I need to add assistant, update the options of the select with a list of all assistant available dynamically,
I'm building the editor, calling in ajax the list of assistant, and updating select options after create the editor.
All work except when i'm submit informations, i'm loosing the Staff information in POST element send.
Can you help me to understand ?

$('#assitant').on( 'click', function (e) {
        e.preventDefault();
        var options = [];
        $.ajax({
            ...
            success: function (json) {
                    options = JSON.parse(json);
            editor
                .create(
                    "New assistant",
                    { "label": "New assistant", "fn": function () { editor.submit() } }
                    )
                    .field('staff').update(options);
            }
        });
    });
editor = new $.fn.dataTable.Editor( {
        ajax: 'staff.php',
        fields: [
            ...
            {
                label: "Assistant",
                name: "staff",
                type:"select",
                options: []
            },
            ...
        ]
    });
}

Regards,


Viewing all articles
Browse latest Browse all 3744