Skip to Content
Menu
This question has been flagged
1 Reply
6157 Views

I want to add class only when $_first evaluated to true

Example:   

 <div t-attf-class="carousel-item {{ $_first }}">

To be:

Incase True:  <div t-attf-class="carousel-item active">

Incase of false: <div t-attf-class="carousel-item">

Avatar
Discard
Author

Thanks Parth, It's works.

Author

Could you Please explain what the meaning of (and 'active' or ' ') and how odoo evaluate it

Best Answer

Try this one

<t t-foreach="records" t-as="rec">
    <div t-attf-class="carousel-item #{ rec_first and 'active' or '' }">
    </div>
</t>
it is not $_first you should replace $ with the value of t-as


Avatar
Discard
Related Posts Replies Views Activity
0
Mar 24
274
0
Oct 22
1489
0
Sep 22
660
1
Jul 22
4084
0
Jun 22
836