How does one obtain the Selectize object to use the update() function?

How does one obtain the Selectize object to use the update() function?

ghherlinghherlin Posts: 20Questions: 3Answers: 0

I have a field in an inline Editor which is type='selectize'.
This field is to be lazily loaded by an ajax call to a server.
All of the preliminaries up to the lazy call to the server and return of the data work. The selectize "selector" displays, but is empty (unsurprisingly, as that is the
But I have not been able to call the update(...) function (the Chrome debugger says

Uncaught (in promise) TypeError: $(...).selectize.update is not a function

)
Moreover, it is not clear to me how the parameters for update(...) should be used.

The documentation does not fully describe the update() function, and no example of this is provided.

Several days of reading the documentation of selectize and the code provided yielded no insight.
Help?

Thanks in advance,
George

This question has an accepted answers - jump to answer

Answers

  • rf1234rf1234 Posts: 2,801Questions: 85Answers: 406

    https://editor.datatables.net/reference/api/field().update()
    does not work for selectize. It only works for this:

    If you want to update the options for a selectize field you need to dynamically drop and add the respective field to Editor. If you search for selectize and rf1234 in this forum you should find an example on how this works. If you don't, just get back to this post and let me know.

  • ghherlinghherlin Posts: 20Questions: 3Answers: 0

    Thank you for that. Hmmm... That seems rather heavy-handed.

    It seems, reading the Select2 docs (and your site) that "updating" options dynamically is supported in Select2.

    In your opinion, should I be trying that instead of Selectize?

    Gehroe

  • rf1234rf1234 Posts: 2,801Questions: 85Answers: 406

    I don't know to be honest. I wanted to stick to selectize and did the dynamic field adding and dropping. You have more code when changing the options but you have less code for the initial field definition. For me it was ok ...

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Hi,

    The Selectize plug-in for Editor does actually support an update() method which works in a similar way to the field().update() method available for the built in form types (although it doesn't support an append option).

    You would use it in much the same way:

    editor.field('myField').update([
      // ... options
    ]);
    

    Allan

Sign In or Register to comment.