1

I have the following code:

 <t groups="website_sale.group_website_multi_image">
  <t t-set="variant_img" t-value="any(product.mapped('product_variant_ids.image_variant'))"/>
  <t t-set="image_ids" t-value="product.product_image_ids"/>
  <div id="o-carousel-product" class="carousel slide" data-ride="carousel" data-interval="0">
    <div class="carousel-outer">
      <div class="carousel-inner">
        <div t-if="variant_img" class="item active" itemprop="image" t-field="product.product_variant_id.image" t-options="{'widget': 'image', 'class': 'product_detail_img js_variant_img', 'alt-field': 'name', 'zoom': 'image', 'unique': product['__last_update'] + (product.product_variant_id['__last_update'] or '')}"/>
    <ol class="carousel-indicators" t-if="len(image_ids) or variant_img">
      <li data-target="#o-carousel-product" t-att-data-slide-to="1 if variant_img else 0" t-att-class="'' if variant_img else 'active'">
        <img class="img img-responsive" t-attf-src="/website/image/product.template/{{product.id}}/image/90x90" t-att-alt="product.name"/>
      </li>
      <t t-if="len(image_ids)" t-foreach="image_ids" t-as="pimg">
        <li data-target="#o-carousel-product" t-att-data-slide-to="pimg_index + (variant_img and 2 or 1)">
          <img class="img img-responsive" t-attf-src="/website/image/product.image/{{pimg.id}}/image/90x90" t-att-alt="pimg.name"/>
        </li>
      </t>
    </ol>
  </div>
</t>
<script language="javascript" type="text/javascript">

    <MY SCRIPT>

</script>

inside the 'script' tag i need to read one of the qweb variable, I need the {{product.id}}, to load a dinamic path in javascript.

I've tryied a lot of variants:

var WRProdId ="{{product.id}}";

also:

<input type="hidden" id="Current360Product" name="Current360Product" value="{{product.id }}"/> 

<script language="javascript" type="text/javascript"> 
var WRProdId = document.getElementById("Current360Product").value;

but the {{product.id}} is never interpreted

How can I read it?

3
  • What have you try ? Commented Jun 7, 2018 at 7:34
  • I've tryied a lot of variants: var WRProdId ="{{product.id}}"; also <input type="hidden" id="Current360Product" name="Current360Product" value="{{product.id }}"/> <script language="javascript" type="text/javascript"> var WRProdId = document.getElementById("Current360Product").value; but the {{product.id}} is never interpreted Commented Jun 7, 2018 at 7:56
  • Please add this to your question by editing it ;) Commented Jun 7, 2018 at 8:06

2 Answers 2

1

The solution is:

var WRProdId = <t t-esc="product.id"/>;
Sign up to request clarification or add additional context in comments.

Comments

1

The solution is:

var WRProdId = "<t t-esc="product.id"/>";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.