How to initialize a custom field?

How to initialize a custom field?

VyacheslavVyacheslav Posts: 70Questions: 27Answers: 0

As we know Editor creates fields and shares them between calls ... but my custom field's view can be changed during inputting value (i.e. some independent check-boxes can be set or assigned classes etc.) ... I need a callback where I could reset a view of my custom field from previous usage .... or I've missed something?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    If I've understood correctly, I think you would just need to set up the event listeners in the create function for the field type - they would listen for whatever events will trigger the change and then perform that change.

    Allan

  • VyacheslavVyacheslav Posts: 70Questions: 27Answers: 0

    Unfortunately, create fires just once but I want to reset the field every time when Editor is open.

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Answer ✓

    Simply listen for the open event in that case. Add the listener in the create function:

    this.on( 'open', function () {
       ...
    } );
    

    Allan

  • VyacheslavVyacheslav Posts: 70Questions: 27Answers: 0

    Yep! That fits me well! Thank you again)

This discussion has been closed.