How to I access the Selectize instance to use the API
How to I access the Selectize instance to use the API
bigbenchrob
Posts: 26Questions: 9Answers: 2
in Editor
I'd like to alter some aspects of a Selectize field using the API. In answer to a previous question, Alan, you suggested accessing the API using the Selectize plug-in inst() method. I assume the API can only be accessed once the field has actually been generated on the editing form. So I'm trying the following, which is not working. Hopefully a basic lack of understanding on my part? Thanks.
editor = new $.fn.dataTable.Editor( {
//...etc
};
editor.on( 'open', function ( e, type ) {
var fieldSelect = editor.field("field_id_65").inst();
console.log(fieldSelect.getValue());
} );
//CONSOLE: TypeError: fieldSelect.getValue is not a function
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Hi,
I've just completely rewritten the plug-in to address this and a few other little things I found along the way. The
inst()
method will now return the expected instance, and also you don't need to use theopen
event anymore.Allan
You rock, Allan! Thanks very much.
Hi Allan,
What else did this rewritten plugin change? I have code that worked on Friday and foolishly updated without saving the previous version of the plugin. None of my "opts" work anymore. I had placeholder text and a dynamic search load written. I am trying to debug the library but am not sure where the "opts" arguments should be added to the Selectize element. Please help!
Thanks
Darn - sorry about that. I even remember making that mistake ("I'll just do this and come back to that...").
I've just posted an update to the plug-in that should resolve it.
Regards,
Allan
Thank you very much! It worked and the fast turnaround time is greatly appreciated.