hiding in dynamically generated template

hiding in dynamically generated template

nlooijenlooije Posts: 47Questions: 9Answers: 0

Hi,

I am using Editor with a template, which looks something like this:

<div id="testing" class="tab-pane">
    <div class="row">
        <div class="col-sm-6">
            <fieldset id="fields-testing"></fieldset>
        </div>
        <div class="col-sm-6">
            <div class="row">
              <div class="col-sm-12">
                <fieldset id="fields-testing-mfi">
                    <legend>MFI:</legend>
                </fieldset>
              </div>
            </div>
        </div>
    </div>
</div>

I'm populating the <fieldset> with <div data-editor-template='some-field'/> using javascript.
The fields in <fieldset id="fields-testing-mfi"> are dependent on fields in <fieldset id="fields-testing">.
When a specific value is toggled in <fieldset id="fields-testing"> the visibility of fields in <fieldset id="fields-testing-mfi"> are toggled (show/hide in dependent()).
When the <fieldset> is empty, that is doesn't contain any <div>, I would like to hide the <legend>.
Is there any functionality to do this?

Replies

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

    Not built into Editor I'm afraid. Whatever function you are using to do the toggle could alter the display attribute of the legend though? How are you currently doing that toggle?

    Allan

  • nlooijenlooije Posts: 47Questions: 9Answers: 0
    edited August 2023

    I am using dependents() to toggle fields based on other fields
    To give you a visual:

    When clicking certain fields in the REQUIREMENTS field, toggles fields under heading MFI, Gottfert, DSC, TGA etc.
    but if there are no fields then i want to hide the legend also, currently that is not happening.

    I am sure i can hack some way to do it using CSS/Javascript/JQuery, was hoping this was possible through the API somehow.

Sign In or Register to comment.