Enrique Moreno Tent
Enrique Moreno Tent

Reputation: 25297

Hide element if not element in a list iteration

So I have 2 list of string in 2 fields, altText and imagecaption. I have them wrapped in a div. I want to make the div not render if neither have content in some loop, on each iteration of the loop. How can I do it?

            30 = COA
            30{

                wrap = <div class="case-info">|</div>
                required = 1

                30 = TEXT
                30{
                    wrap = <div>|</div>
                    field = altText
                    listNum.splitChar = 10
                    listNum.stdWrap.data = register:SPLIT_COUNT
                    required = 1

                }

                40 < .30
                40.field = imagecaption


            }

The output of html is this:

<div class="case-info">
    <div></div>
    <div></div>
</div>

Upvotes: 3

Views: 541

Answers (1)

maholtz
maholtz

Reputation: 3631

Remove the wrap and try it this way:

        30 = COA
        30{
            stdWrap.required = 1
            stdWrap.wrap = <div class="case-info">|</div>
            30 = TEXT
            30{
                field = altText
                listNum.splitChar = 10
                listNum.stdWrap.data = register:SPLIT_COUNT
                trim = 1
                required = 1
                wrap = <div>|</div>
            }

            40 < .30
            40.field = imagecaption


        }

so, the wrap will only executed, if there is content (required = 1)

Upvotes: 2

Related Questions