Clearing editor field values

Clearing editor field values

abarnesabarnes Posts: 16Questions: 5Answers: 0

Is it possible to have the field value cleared on on editor.bubble? Looking for a way for the user to avoid having to delete the value first before typing.

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @abarnes ,

    This here does the trick - I suspect there may be an easier way, but this will get you going.

    Cheers,

    Colin

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    I'd probably use the open event like this:

      $('#example').on('click', 'tbody tr td', function() {
        editor.bubble(this);
      }); 
      
      editor.on('open', function (e, mode, action) {
        if ( mode === 'bubble' ) {
          editor.displayed().map( fieldName => {
            editor.field(fieldName).set('');
          } );
        }
      });
    

    Doesn't look much easier than Colin's answer though!

    Allan

  • abarnesabarnes Posts: 16Questions: 5Answers: 0

    Awesome. Thanks

  • abarnesabarnes Posts: 16Questions: 5Answers: 0

    Followup, is there any way to get the current value of the field prior to clearing? For example only clear if it says "CLick to edit..."

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @abarnes ,

    Going with Allan's approach, this here will do the trick,

    Cheers,

    Colin

  • abarnesabarnes Posts: 16Questions: 5Answers: 0

    Excellent. Exactly what I needed. Thanks for your help

This discussion has been closed.