Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the value of the data item to use in {{if}}?

I am trying to get the value of the data item to use in a {{if}} tag, but cannot get it to work. So, the question is how do we get that value? You can see full code here http://jsfiddle.net/epitka/BhYvh/

<script id="contentHeaderTemplate" type="text/x-jquery-tmpl">
   {{if($data.Id===1)}} Create New Order{{else}}Edit Order {{/if}}      
    <br />
</script>
like image 934
epitka Avatar asked Feb 25 '23 07:02

epitka


2 Answers

Drop the parentheses.

{{if $data.Id === 1 }}

http://jsfiddle.net/mattball/KdqZF/

See also the {{if}} template tag API page.

like image 169
Matt Ball Avatar answered Mar 05 '23 20:03

Matt Ball


You don't need the parentheses in that if statement. Try: {{if $data.Id === 1 }}

like image 37
Thomas Shields Avatar answered Mar 05 '23 21:03

Thomas Shields