admin 管理员组文章数量: 1086019
Hi I am new to Sencha touch. I have problem displaying data in Ext.dataview.List
with itemTpl
. This how I am setting itemTpl
in config
itemTpl: new Ext.XTemplate(
'<div class="featureImageHolder"><img class="featureImage" src="{itemImage}" alt="{itemName}" /></div>',
'<span class="item">',
'<h3 class="saleName">{itemName}</h3>',
'<span class="priceOptions">',
'<tpl for="prices">',
'<span class="priceOptionReg">',
'<tpl if="priceOptionDesc">{priceOptionDesc}</tpl> ',
'<tpl if="priceOptionReg">{priceOptionReg}</tpl> ',
'<tpl if="priceReg">${priceReg}</tpl> ',
'<tpl if="priceRegSuffix">{priceRegSuffix}</tpl> ',
'</span>',
'<tpl if="priceSale"><span class="priceOptionSale">',
'<tpl if="priceSaleDesc">{priceSaleDesc}</tpl> ',
'<tpl if="priceOptionSale">{priceOptionSale}</tpl> ',
'<tpl if="priceSale">${priceSale}</tpl>',
'<tpl if="priceSaleSuffix">{priceSaleSuffix}</tpl> ',
'</span></tpl>',
'</tpl>',
'</span>',
'</span>',
'<div class="clear"></div>'
),
It is working perfectly and displaying list of products. But now I need change CSS class for first record only because it is an Ad banner. So I am using following if statement:
itemTpl: new Ext.XTemplate(
'<tpl if={isBanner} === true>',
'<div class="myTestClass">{itemImage}</div>',
'<tpl elseif={isBanner} === false>',
'<div class="featureImageHolder"><img class="featureImage" src="{itemImage}" alt="{itemName}" /></div>',
'</tpl>',
'<span class="item">',
'<h3 class="saleName">{itemName}</h3>',
'<span class="priceOptions">',
'<tpl for="prices">',
'<span class="priceOptionReg">',
'<tpl if="priceOptionDesc">{priceOptionDesc}</tpl> ',
'<tpl if="priceOptionReg">{priceOptionReg}</tpl> ',
'<tpl if="priceReg">${priceReg}</tpl> ',
'<tpl if="priceRegSuffix">{priceRegSuffix}</tpl> ',
'</span>',
'<tpl if="priceSale"><span class="priceOptionSale">',
'<tpl if="priceSaleDesc">{priceSaleDesc}</tpl> ',
'<tpl if="priceOptionSale">{priceOptionSale}</tpl> ',
'<tpl if="priceSale">${priceSale}</tpl>',
'<tpl if="priceSaleSuffix">{priceSaleSuffix}</tpl> ',
'</span></tpl>',
'</tpl>',
'</span>',
'</span>',
'<div class="clear"></div>'
),
The problem is if/elseif
are both executed for each record. If I use if/else
it gives error in console.
Uncaught SyntaxError: Unexpected token else
You can see I have used
'<tpl if={isBanner} === true>',
I have also used
'<tpl if={isBanner} == true>',
I have also tried many varients like paring numeric values instead of Boolean and using >
or <
. Also tried paring String values. But with all variations, the if/elseif
are both executing and if/else
gives error.
Any help is appreciated, I just need to change class for first record.
Hi I am new to Sencha touch. I have problem displaying data in Ext.dataview.List
with itemTpl
. This how I am setting itemTpl
in config
itemTpl: new Ext.XTemplate(
'<div class="featureImageHolder"><img class="featureImage" src="{itemImage}" alt="{itemName}" /></div>',
'<span class="item">',
'<h3 class="saleName">{itemName}</h3>',
'<span class="priceOptions">',
'<tpl for="prices">',
'<span class="priceOptionReg">',
'<tpl if="priceOptionDesc">{priceOptionDesc}</tpl> ',
'<tpl if="priceOptionReg">{priceOptionReg}</tpl> ',
'<tpl if="priceReg">${priceReg}</tpl> ',
'<tpl if="priceRegSuffix">{priceRegSuffix}</tpl> ',
'</span>',
'<tpl if="priceSale"><span class="priceOptionSale">',
'<tpl if="priceSaleDesc">{priceSaleDesc}</tpl> ',
'<tpl if="priceOptionSale">{priceOptionSale}</tpl> ',
'<tpl if="priceSale">${priceSale}</tpl>',
'<tpl if="priceSaleSuffix">{priceSaleSuffix}</tpl> ',
'</span></tpl>',
'</tpl>',
'</span>',
'</span>',
'<div class="clear"></div>'
),
It is working perfectly and displaying list of products. But now I need change CSS class for first record only because it is an Ad banner. So I am using following if statement:
itemTpl: new Ext.XTemplate(
'<tpl if={isBanner} === true>',
'<div class="myTestClass">{itemImage}</div>',
'<tpl elseif={isBanner} === false>',
'<div class="featureImageHolder"><img class="featureImage" src="{itemImage}" alt="{itemName}" /></div>',
'</tpl>',
'<span class="item">',
'<h3 class="saleName">{itemName}</h3>',
'<span class="priceOptions">',
'<tpl for="prices">',
'<span class="priceOptionReg">',
'<tpl if="priceOptionDesc">{priceOptionDesc}</tpl> ',
'<tpl if="priceOptionReg">{priceOptionReg}</tpl> ',
'<tpl if="priceReg">${priceReg}</tpl> ',
'<tpl if="priceRegSuffix">{priceRegSuffix}</tpl> ',
'</span>',
'<tpl if="priceSale"><span class="priceOptionSale">',
'<tpl if="priceSaleDesc">{priceSaleDesc}</tpl> ',
'<tpl if="priceOptionSale">{priceOptionSale}</tpl> ',
'<tpl if="priceSale">${priceSale}</tpl>',
'<tpl if="priceSaleSuffix">{priceSaleSuffix}</tpl> ',
'</span></tpl>',
'</tpl>',
'</span>',
'</span>',
'<div class="clear"></div>'
),
The problem is if/elseif
are both executed for each record. If I use if/else
it gives error in console.
Uncaught SyntaxError: Unexpected token else
You can see I have used
'<tpl if={isBanner} === true>',
I have also used
'<tpl if={isBanner} == true>',
I have also tried many varients like paring numeric values instead of Boolean and using >
or <
. Also tried paring String values. But with all variations, the if/elseif
are both executing and if/else
gives error.
Any help is appreciated, I just need to change class for first record.
Share Improve this question asked Mar 6, 2014 at 9:25 KhawarKhawar 9,2519 gold badges47 silver badges67 bronze badges1 Answer
Reset to default 6if isBanner is boolean, this will work
'<tpl if="isBanner">',
'<div class="myTestClass">{itemImage}</div>',
'<tpl else>',
'<div class="featureImageHolder"><img class="featureImage" src="{itemImage}" alt="{itemName}" /></div>',
'</tpl>',
本文标签: javascriptSencha touchExtXTemplate ifelse not workingStack Overflow
版权声明:本文标题:javascript - Sencha touch - Ext.XTemplate ifelse not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1743988342a2514261.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论