Trigger dependent with custom field-type plugins
Trigger dependent with custom field-type plugins
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
This discussion has been closed.
Answers
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 thedependent()
call) on the node(s) returned byfield().input()
.By default
field().input()
will selectinput
,select
andtextarea
elements from the field's DOM structure. However, you can define your owninput
method in the field definition which will overrule that. For example: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
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