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

I need to pass a value from js to qweb template, this error raised. 

Thanks in advance

JS


onclick_contacts:function(event) {
var self = this;
ajax.jsonRpc("/messages/all_messages","call",{
}
).then(function(all_messages){
self.all_messages = all_messages;
var contacts = self.all_messages;
var options = contacts;
self.options = options;
self.$('.show_contact').html(QWeb.render('mail.systray.MessageMenu',{
values:options, widget:self
}));
})
},

QWEB


<div class="o_mail_systray_dropdown_items">
<div class="show_contact">
<t t-foreach="widget.options" t-as="option">
<t t-esc="option"/>
</t>
</div>
</div>

ERROR

Uncaught Error: QWeb2 - template['mail.systray.MessageMenu']: No enumerator given to foreach
http://192.168.2.25:8089/web/content/401-7f32d5f/web.assets_common.js:3374
Traceback:
Error: QWeb2 - template['mail.systray.MessageMenu']: No enumerator given to foreach
at Object.exception (http://192.168.2.25:8089/web/content/401-7f32d5f/web.assets_common.js:3374:7)
at Object.foreach (http://192.168.2.25:8089/web/content/401-7f32d5f/web.assets_common.js:3388:80)
at Engine.eval (eval at _render (http://192.168.2.25:8089/web/content/401-7f32d5f/web.assets_common.js:3416:73), <anonymous>:27:23)
at Engine._render (http://192.168.2.25:8089/web/content/401-7f32d5f/web.assets_common.js:3415:296)
at Engine.render (http://192.168.2.25:8089/web/content/401-7f32d5f/web.assets_common.js:3415:151)
at Engine._render (http://192.168.2.25:8089/web/content/401-7f32d5f/web.assets_common.js:3419:57)
at Engine.render (http://192.168.2.25:8089/web/content/401-7f32d5f/web.assets_common.js:3415:151)
at Class.renderElement (http://192.168.2.25:8089/web/content/401-7f32d5f/web.assets_common.js:3674:1014)
at http://192.168.2.25:8089/web/content/401-7f32d5f/web.assets_common.js:3684:6
at http://192.168.2.25:8089/web/content/401-7f32d5f/web.assets_common.js:802:681

Avatar
Discard
Best Answer

The loop in QWeb you are executing don't contain any values so causing this error. The issue is  in <t t-foreach="widget.options" t-as="option"> this code.


Avatar
Discard
Related Posts Replies Views Activity
0
Jul 19
163
2
Oct 22
4552
3
Sep 21
10607
1
May 21
1769
2
Mar 21
2510