Show/Hide Editor fields

Show/Hide Editor fields

btreebtree Posts: 99Questions: 14Answers: 11
edited October 2015 in Editor

Hi there,

I dont know if it is too late and I miss anything crucial? I want to show/hide specific editor fields when the user changes a certain dropdown field in editor.

The code is working but only for one time? The console.log(id) looks good and gets called but the hide and show function does only work on the first change?

The code is inside editor.on('initCreate'

editor.hide( 'queen.mother');   
$(editor.field( 'mother_action' ).node()).on('change', function () {
            var id = editor.field( 'mother_action' ).val();
            if (id === 1){              
                editor.hide('queen.mother');
                editor.show('queen.mother_id');
                //editor.field('queen.mother').hide();  
                //editor.field('queen.mother_id').show(); 
                console.log(id);                
            } else {
                editor.show('queen.mother');
                editor.hide('queen.mother_id');
                //editor.field('queen.mother').show();          
                //editor.field('queen.mother_id').hide();   
                console.log(id);        
            }
});

Cheers
Hannes

This question has an accepted answers - jump to answer

Answers

  • btreebtree Posts: 99Questions: 14Answers: 11
    edited October 2015

    Hi,

    moved it inside editor.on('open' ....

    There it works.

    Cheers
    Hannes

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Good to hear you've got it working - thanks for posting back!

    Allan

This discussion has been closed.