Setting the title of the editor lightbox

Setting the title of the editor lightbox

LimpEmuLimpEmu Posts: 65Questions: 18Answers: 1

I have read the examples and looked through previous questions. It seems that to replace the title of the editor lightbox mod, this should work:

editor.on( 'initEdit', function ( e, json, data ) {                                                              
    editor.field('id').disable();                                              
    editor.field('user_comment').disable(); 
    editor.field('rbrslvd').disable(); editor.field('cbrslvd').disable();
    editor.title('Issue ' +data.thisid);                                                                         
}

It does not however, what am I missing? Thank you!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin
    Answer ✓

    Hi,

    Editor actually sets the title after the initEdit event is triggered, which is why your title appears to get overwritten (it is being!).

    Use open instead:

    editor.on( 'open', function ( e, mode, action ) {
      if ( mode === 'edit' ) {
        editor.title('Edit: ' + editor.field('...').val() );
      }
    } );
    

    Allan

  • LimpEmuLimpEmu Posts: 65Questions: 18Answers: 1

    This worked perfectly, thank you!

  • hnhegdehnhegde Posts: 68Questions: 17Answers: 0

    Hi @allan ,
    Shouldn't the check be:
    if ( action === 'edit' ) ?

    Regards,
    Harsha

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Hi @hnhegde ,

    Yep, slight typo on Allan's part. It should probably be a third option though :)

    if (action === 'edit' && mode === 'main' )
    

    That'll capture the case if you're also inline or bubble editing,

    Cheers,

    Colin

  • hnhegdehnhegde Posts: 68Questions: 17Answers: 0

    Agreed. thanks!

    Regards,
    Harsha

This discussion has been closed.