0

How can i get die value of a field folder.x_code inside a div script data-configid

<t t-foreach="website.env['x_folders'].search([])" t-as="folder"> <!-- BEGINLOOP -->
              <t t-if="folder.x_actief">
              <div class="col-md-4 text-center">
                <div class="box">
                  <div class="box-content">
                      <h1 t-field="folder.x_name" style="font-size: medium"/>
                    <hr/>

<div data-configid="<t t-esc="folder.x_code"/>" 
style="width:100%; height:371px;" class="issuuembed"></div>                       
                    <script type="text/javascript" src="//e.issuu.com/embed.js" async="true"></script>
                    <br/>
                  </div>
                </div>
              </div>
              </t></t>
Pelingier
  • 145
  • 2
  • 15

2 Answers2

1

The solution thx to Veikko

<t t-foreach="website.env['x_folders'].search([])" t-as="folder">
  <t t-if="folder.x_actief">
     <div class="col-md-4 text-center">
      <div class="box">
        <div class="box-content">
          <h1 t-field="folder.x_name" style="font-size: medium"/>
          <hr/>
          <div t-attf-data-configid="{{folder.x_code}}" style="width:100%; height:371px;" class="issuuembed"></div>                       
          <script type="text/javascript" src="//e.issuu.com/embed.js" async="true"></script>
          </div>
       </div>
       </div>
      </t>
    </t>
Pelingier
  • 145
  • 2
  • 15
0

You can use t-attf-$name syntax in QWeb like this:

<div t-attf-data-configid="{{folder.x_code}}"></div>

I have not used this with data attributes but I see no reason for it not to work with those too. Please give feedback if it works! You can find more information on qweb from Odoo reference at https://www.odoo.com/documentation/11.0/reference/qweb.html#attributes.

Br,

Veikko

Veikko
  • 3,372
  • 2
  • 21
  • 31
  • Thx its works there is only 1 typo in your code t-att-data-configid should be **t-attf-data-configid** – Pelingier Mar 15 '18 at 07:12
  • 1
    Good that this helped you. Sorry for the typo. Good that you spotted the typo quickly! I fixed it in my answer. Also the quotation marks were weird. That is also fixed. – Veikko Mar 15 '18 at 15:05