开发者

sencha touch :: how to pass index-Id from list into XTemplate function

开发者 https://www.devze.com 2023-03-19 12:04 出处:网络
I want to create a dynamically variating list with XTemplates. unfort. you can\'t pass the index-id though a function within an if-construct like

I want to create a dynamically variating list with XTemplates. unfort. you can't pass the index-id though a function within an if-construct like

var newItemTpl = '<div class="list_websites_item"><div class="' + cmp.id + '">' + orgItemTpl + '</div>' + '<div class="iconset">' + 
'<tpl if="Ext.getCmp(\'' + cmp.id + '\').plugins[0].isPendingItem({[xindex-1]})">'+
    '<p>IS PENDING</p>'+
  '</tpl>' +
'</d开发者_开发技巧iv></div>';

when I call isPendingItem({[xindex-1]}) with argument I get the error

SyntaxError: Parse error

So how could I pass arguments here?

thnx!!!


You can access the in-built template variables (xindex, xcount, values etc) directly within an if tag so if you change your code to remove the enclosing '{[]}' then it should work:

var newItemTpl = '<div class="list_websites_item"><div class="' + cmp.id + '">' + 

orgItemTpl + '</div>' + '<div class="iconset">' + 
'<tpl if="Ext.getCmp(\'' + cmp.id + '\').plugins[0].isPendingItem(xindex-1)">'+
    '<p>IS PENDING</p>'+
  '</tpl>' +
'</div></div>';
0

精彩评论

暂无评论...
验证码 换一张
取 消