Adding the data parameter to the Editor open event

Adding the data parameter to the Editor open event

FurburgerFurburger Posts: 37Questions: 8Answers: 0

When loading an Editor form, it is often useful to have access to the data that is going to be inserted into the form. For example, I am loading a child table in the form and I need the parent id of the form data to filter the data before the form is loaded

Unfortunately, the open does not have it.

The initEdit does not have it, but it is called too early - the form is not in the DOM at this stage.

It would be great if all the events had the data parameter to make it consistent. For example, the initCreate should also have it, but it would be an empty object.

Then we can safely always refer to the data object and handle cases where it is empty or has data.

Basically, the more information you can give developers in the event parameters the better - even the mode so we don't have to write code to get the Editor's mode.

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    The initEdit does not have it, but it is called too early - the form is not in the DOM at this stage.

    I think there is an extra not in there. The initEdit event does give the data being edited.

    What you could do is use:

    editor.on( 'initEdit', function ( e, node, data ) {
      editor.on( 'open', function () {
        ... use `data`
      } );
    } );
    

    I'm not entirely clear why you need the field to be available in the document to make able to make use of it? You can use field().node() to get the field's node should you wish to manipulate it.

    Allan

This discussion has been closed.