Show/Hide with Toggle

Toggle containers with show and hide. I have two grid containers with the class damage and no_damage and want them to show and hide with a toggle:

fd.spRendered(function () {
const t = fd.field('Damage');
function apply() {
const on = t.value === true;
fd.$('.no_damage').toggle(!on);
fd.$('.damage').toggle(on);
}
apply();
t.$on('change', apply);
});

Somehow it does not work

Hi @pauli99,

Try this:

fd.spRendered(function () {
    const t = fd.field('Damage');
    
    function apply() {
        if (t.value) {
            $('.no_damage').hide();
            $('.damage').show();
        } else {
            $('.no_damage').show();
            $('.damage').hide();
        }
    }
    
    apply();
    t.$on('change', apply);
});

I´ve tried it, and it works!