How does one obtain the Selectize object to use the update() function?
How does one obtain the Selectize object to use the update() function?
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
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.
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
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 ...
Hi,
The Selectize plug-in for Editor does actually support an
update()
method which works in a similar way to thefield().update()
method available for the built in form types (although it doesn't support anappend
option).You would use it in much the same way:
Allan