Standalone and CkEditor field

Standalone and CkEditor field

perrotinperrotin Posts: 39Questions: 9Answers: 1

Hi,
I'm trying to insert a field type CkEditor in my standalone page, this works well except that modifications aren't be taken because "Enter" key isn't valid the modifcations (like with other field) because it made a carriage return.
How can i update the modifications made with a CkEditor field ?
Thanks.

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    You will need a submit button that calls the submit() method. This example shows how you can have a submit button.

    Allan

  • perrotinperrotin Posts: 39Questions: 9Answers: 1

    OK, so I've tried to put an event on the preClose or Close event of editor that check if it's a ckeditor fields for updating.
    This work well when i'm putting value in variable test :
    standalone.set(field,test)

    but how can i get the data from the ckeditor ? i've try this but not working :
    standalone.set(field,CKEDITOR.getData())

    Best Regards.

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    To get the field value you should be able to use field().val() or val().

    Allan

  • perrotinperrotin Posts: 39Questions: 9Answers: 1

    Hi Allan.
    Thanks for answer.
    But I'm still can't get field value when i'm putting it on event preClose.
    If I put a console log on the preClose, it return "Null", but if i call the value with a button event, the same code return the right value.

    I try this :

    standalone.on('init',function( e,data,opts,json){
        editor = standalone.Editor();
        ...
    }).on('draw',function( e,data,opts){
        ...
        editor.on( 'preClose', function ( e ) {
            console.log(editor.field('name_of_field').val());
        });
    });
    
    $(document).on('click','#test',function(){
        console.log(editor.field('name_of_field').val());
    });
    

    Where I'm wrong ? i was thinking that preClose event still having the editor accessible and so the value of field too.

    Best regards.

  • perrotinperrotin Posts: 39Questions: 9Answers: 1

    Hi Allan.
    I finally found how, i've put the code in the event preBlur and call event submit next. This work well.
    Event preClose and Close lose the value when calling it.
    Thanks for your help.

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Hi,

    Thanks for the update. Great to hear you've got it working the way you need!

    Regards,
    Allan

This discussion has been closed.