How to hide a column in jquery template

183 Views Asked by At

I am using jquery template to populate order details. I have a hidden field, based upon its value, I need to hide or show a specific column. How to do it. My code look like below

<script id="TestTemplate" type="text/x-jquery-tmpl">        
        <tr id="trOrderDetail">
             <td align="right">${order_id}</td>      
            {{ if document.getElementById('hdnShowQty').value == "0" }}
             <td align="right">${qty}</td>
            {{/if}} 
        </tr>
    </script>

I tried it, but it is not working.

1

There are 1 best solutions below

0
user1926138 On

I got the code working. There is space between {{ and if , }} and "0". So correct code is as below

<script id="TestTemplate" type="text/x-jquery-tmpl">        
        <tr id="trOrderDetail">
             <td align="right">${order_id}</td>      
            {{if document.getElementById('hdnShowQty').value == "0"}}
             <td align="right">${qty}</td>
            {{/if}} 
        </tr>
    </script>