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

Losing select2 field value when loading options via ajax

$
0
0

I have a select2 field (problem_field) whose options depend on the value of another field (dependant_field).
I update the options with:

editor.dependent("dependant_field", function (val) {
  $.ajax({
            type: "POST",
            ...,
            success: function (options) {
                editor.field("problem_field").update(options);
    });

If I remove the ajax call and load the options directly then it works.
If I leave the ajax call in place and change the field type to "select" then it works.

So it seems that select field allows you to set value not in options, but select2 does not.
Is there a work around to this?
Something I can do in initEdit to save the field values, and set them after field().update() ?

Kind regards,
Kevan


Viewing all articles
Browse latest Browse all 3740

Trending Articles