In editor form, how to initiate set() of some fields based on data entered in another?
In editor form, how to initiate set() of some fields based on data entered in another?
I have a form with name, age, gender. I want the user to be able to select a name from a set of selectize choices, and have the form automatically fill in age and gender based on some lookups within my javascript code.
I could not readily find an event to catch, after a field is entered, to put my code within an on condition.
Is this feature available? How can I make use of it?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
or I guess maybe I can use raw jquery for this after on('open'...). Am I getting that right?
You could just listen for the
change
event (I'm assuming that Selectize will trigger that on theselect
element). You can get theselect
usingfield().input()
(edit method corrected).Allan
Just clarifying for future readers.
field()
does not seem to have anyselect()
function, per http://editor.datatables.net/plug-ins/field-type/editor.selectizeI think I need to use
field(name).inst().on()
to set an event handler for a selectize field.I'm afraid I don't quite understand - I don't see anything on the page you linked to suggesting that there would be a
select()
method for the field (unless I've misunderstood).Edit Sorry - i see my typo in the above now - it should be
field().input()
- I'll correct it.Allan
Thanks. I'll check out
field().input()
, but notefield().inst().on()
also works for selectize field.