Trigger dependent with custom field-type plugins

Trigger dependent with custom field-type plugins

Maha80Maha80 Posts: 30Questions: 10Answers: 1

Hi Allan,

I have written a custom field type plugin with svg user interface. There are no html input elements. How can I make the plugin to trigger editor.dependent() for fields of this type, when changing values?

Thank you for your help.

Best regards
Martin

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Hi Martin,

    The way dependent() works is to place an event listener (change by default, although it can be changed using the options passed into the dependent() call) on the node(s) returned by field().input().

    By default field().input() will select input, select and textarea elements from the field's DOM structure. However, you can define your own input method in the field definition which will overrule that. For example:

    input: function ( conf ) {
      return ...;
    }
    

    So basically, have that function return a node that will have an event triggered on it so dependent() can listen for it.

    Sounds like an interesting plug-in!

    Regards,
    Allan

  • Maha80Maha80 Posts: 30Questions: 10Answers: 1

    Hi Allan,

    Awesome! Again thank you very much for your help! I did several field-type plugins now with D3. As soon as I am finished with my app, I will send you a link...

    Best regards
    Martin

This discussion has been closed.