Update select options, losing the field when submit

Update select options, losing the field when submit

perrotinperrotin Posts: 39Questions: 9Answers: 1
edited July 2016 in Editor

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,

This question has an accepted answers - jump to answer

Answers

  • perrotinperrotin Posts: 39Questions: 9Answers: 1
    Answer ✓

    Ok I found, i forgot the staff field in my EDITOR:inst.
    Now that's work well.
    Thanks

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Thanks for posting back - good to hear you have it working!

    Allan

This discussion has been closed.