I have a button "Add attribute".On clicking I want to hide other fields by calling a javascript function ..
How to implement that
I have inclided a template like this for calling javascript
<template id="web_assets_frontend" name="website_variant_assets" inherit_id="website.assets_frontend">
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/website_variants/static/src/js/website_variant.js"></script>
</xpath>
</template>
My button is this:
<input type="button" onclick="myfunction()"
class="btn btn-primary" value="Add Attribute"
style="margin:10px 0 0 0"></input>
myfunction is the javascript function which I have to call
Now my myfunction is this:-
function myfunction()
{
var y = document.getElementById("hide_button");
if (y.style.display === "none")
{
y.style.display = "block";
}
else
{
y.style.display = "none";
}
}
How to implement this myfunction in odoo12
Please Help..
Thanks in Advance
First of all you need to define button like this : -
<button class="btn btn-primary" id="button_id" t-attf-style="width:193px;height:50px;">Add Attribute</button>
Use this below code of js :-
self.$('#button_id').click(function (e){
// Find the element and do the whatever you want.
self.$('#hide_button').css('display','none');
self.$('#hide_button').css('display','block');
});