', '

Xtemplate if conditions in sencha touch

I have the following Xtemplate code:

('Ext.XTemplate', '<div class="moreArrow"></div>', '<div class="img"><img src="http://localhost/WL2/assets/rest/{image}"/></div>', '<div class="meta">', '<h3>{merchName}</h3>', '<div class="actions">', '<button class="seen{[values.seen ? " selected" : ""]}">{action}</button>', '{% if (values.seen) { %}', '<button class="thumb up{[values.like ? " selected" : ""]}"><b></b></button>', '<button class="thumb down{[values.dislike ? "selected" : ""]}"><b></b> </button>', '{% } else { %}', '<button class="want{[values.wantToSee ? "selected" : ""]}">Want to Go There</button>', '{% } %}', '</div>', '</div>' ) 

My problem is that the if condition in the part {% if (values.seen) { %} does not work, that is, when the button is pressed, it should show two hostility buttons, etc. What is wrong with my code that causes this problem?

+4
source share
2 answers

It may not work because you are not comparing it to anything.

By the way, here are a few examples to understand how to use the if condition:

Using comparison operators:

 <tpl if="totalDiscount &gt; 0"> 

Using the AND operator

 <tpl if="active == true && available == true"> 

Using XTemplates Variables:

 '{% if (xindex % 2 === 1) { %}' + '<div>Odd Row</div>' + '{% } %}' 
+8
source

I do not think you are using XTemplate correctly. Check the documentation and try replacing your terms with the <tpl if>

0
source

All Articles