This question has been flagged
4 Replies
9309 Views

I'm trying to show/hide content of a div with specific ID. Normally I would use the jquery hide(), show() commands. Can someone give me an example how to use hide, show in a qweb template or is there a better way to do this?

And I have read the documentation for QWEB and javascript, but I don't get it. So please no copy/paste the example from the documentation.  

Avatar
Discard
Best Answer

For example:

you can use the t-if attribute with templates. For more reference have a look at website templates .

<div t-if="object.val == 'x'">
    ....
</div>
Avatar
Discard
Author

ok... I know how to use t-if, and I'm using it to show divs after submit, but I don't know how to use javascript or jquery in QWEB templates to show hide data without reloading the page.

Okay, then you should try with some hidden classes. Add some hidden class according to your condition using jquery to the div. bootstrap already have hidden classes. Here are some references of helper classes already inbuilt in bootstrap.

On Tue, Jul 17, 2018 at 11:32 AM, Samo Arko <samo.arko@tabla.si> wrote:

ok... I know how to use t-if, and I'm using it to show divs after submit, but I don't know how to use javascript or jquery in QWEB templates to show hide data without reloading the page.

--
Samo Arko

Sent by Odoo S.A. using Odoo.




--
Hilar AK  Python / Odoo Developer

m: +917736617619
e: hilarak@gmail.com
Follow me:
twitteryoutubegithubstack-overflow


Best Answer

This is just an idea.

<script>        
    function reply_click(clicked_id)       
    {           
        $("p").toggle();       
    };       
</script>
<button  onClick="reply_click(this.id)" t-att-id="'hide' +  str(i)" type="button">+</button> 


Avatar
Discard

thank you!