تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
6213 أدوات العرض

Here is my template code

<t t-name="add_product" owl="1">
   <t t-foreach="productList" t-as="product">
       <!-- code to show products -->
   </t>
</t>

I need this template to render inside some div tag while the user clicks on the button

I tried below things

QWeb.render('add_product', {'productList': productList});  

this does not work because the template is owl type.


So I tried to find how to render the owl template and find the below doc but it does not help me.

https://github.com/odoo/owl/blob/master/doc/reference/qweb_engine.md

Any help really appreciated.

Thanks.

الصورة الرمزية
إهمال
أفضل إجابة

Hi Tejas, its kind of late but I stumbled on the same problem years later. In v16, you could use renderToString​ from  "@web/core/utils/render"​ like bellow

import { renderToString } from "@web/core/utils/render";
..
var youContextData = {};
var $content = window.$(
​renderToString('your_owl_template_here', yourContextData)
);



الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
سبتمبر 22
2438
1
مايو 22
2183
0
مايو 21
19
2
يونيو 25
1177
0
مايو 25
12