Dynamic editor form based on select?

Dynamic editor form based on select?

multiPASS-ACmultiPASS-AC Posts: 2Questions: 1Answers: 0
edited June 2018 in Free community support

Apologies if this question is a duplicate - I searched around and couldn't find a solution, but perhaps my searching wasn't optimal. Anyway, I have a page that has an editor, which has a just a couple of fields:

editor = new $.fn.dataTable.Editor({

fields: [{ 
  type:"select", label:"Test", name:"test", 
  options: [ 
     {label:"Option 1", value:"opt1"},
     {label:"Option 2", value:"opt2"}]
}]});

What I want is to add other fields to the editor based on selection of Option 1 / Option 2. I suspect the solution for this is to have an event that fires when the "test" selection is made - but not sure a) how to wire up that event and b) how to create different forms - I think I would have to create some templates for each option, but again not sure.
Thanks!
Andy

This question has an accepted answers - jump to answer

Answers

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

    Hi Andy,

    Have a look at this example which sounds like it is what you are looking for.

    Allan

  • multiPASS-ACmultiPASS-AC Posts: 2Questions: 1Answers: 0

    Perfect! Thanks!

This discussion has been closed.