Pelingier
Pelingier

Reputation: 127

Qweb value inside code in odoo website view

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>

Upvotes: 0

Views: 645

Answers (2)

Veikko
Veikko

Reputation: 3610

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

Upvotes: 0

Pelingier
Pelingier

Reputation: 127

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>

Upvotes: 1

Related Questions