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?

loukinglouking Posts: 259Questions: 52Answers: 0

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

Answers

  • loukinglouking Posts: 259Questions: 52Answers: 0

    or I guess maybe I can use raw jquery for this after on('open'...). Am I getting that right?

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited February 2016

    You could just listen for the change event (I'm assuming that Selectize will trigger that on the select element). You can get the select using field().input() (edit method corrected).

    Allan

  • loukinglouking Posts: 259Questions: 52Answers: 0
    edited February 2016

    Just clarifying for future readers.

    field() does not seem to have any select() function, per http://editor.datatables.net/plug-ins/field-type/editor.selectize

    I think I need to use field(name).inst().on() to set an event handler for a selectize field.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited February 2016 Answer ✓

    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

  • loukinglouking Posts: 259Questions: 52Answers: 0

    Thanks. I'll check out field().input(), but note field().inst().on() also works for selectize field.

This discussion has been closed.