Editor 1.4 dependent - shouldn't it fire if the modal is opened for edit ?

Editor 1.4 dependent - shouldn't it fire if the modal is opened for edit ?

QuaselQuasel Posts: 18Questions: 3Answers: 0

e.g location shouldn't be displayed on edit either - if its a VP

editor.dependent( 'position', function ( val, data, callback ) {
    return val === 'VP' ?
        { hide: 'location' } :
        { show: 'location' };
} );

Did try
{event: 'change initEdit'}
but i think it just listen for events of the field ...

Answers

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

    Hi,

    Yes, that should work. I'm unfortunately away from my main machine at the moment (back tomorrow) so I can't test this just now (unless you are able to link to a test page?), but I will do so tomorrow and let you know how I get on.

    Allan

  • QuaselQuasel Posts: 18Questions: 3Answers: 0

    Sorry no Test Page ;) internal Testing - couldn't it get to work

                editor_plc.dependent('bwrb_rel.id', function (val, data, callback) {
                        console.log(val);
                        console.log(data);
                        console.log(callback);
                    },
                    {event: 'change initCreate initEdit'}
                )
    

    just get output on change, or when the select list is updated ...

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

    Hi,

    Sorry for the delay in looking into this! I've just tried it locally and it does appear to work as expected. Using this example run the following on your console:

        editor.dependent( 'users.site', function ( val, data, callback ) {
            return val === '2' ? // London
                { hide: 'users.phone' } :
                { show: 'users.phone' };
        } );
    

    If a row with London is selected for editing, the phone input field is hidden. Otherwise it is shown.

    One thing I notice - your dependency is on bwrb_rel.id which I guess is an integer? But you are testing against a string?

    Allan

  • QuaselQuasel Posts: 18Questions: 3Answers: 0

    I found the issue:
    seems it doesn't work with select2 fields ... for any kind of modal it just works on a "change" event ...

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

    I think the select2 plug-in will need a little update to correctly handle this. I'll post back here when I've done so.

    Allan

  • QuaselQuasel Posts: 18Questions: 3Answers: 0

    any progress onthe issue?

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

    Yes - sorry for the delay! I've just updated the plug-in. With that code the dependent method should work as expected (it does in my testing).

    Allan

This discussion has been closed.