2011-07-12 41 views
1

我想用XTemplates創建一個動態變量列表。 unfort。你無法通過內部索引ID雖然功能的,如果,構建像sencha touch ::如何將index-id從列表傳遞到XTemplate函數

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>'; 

當我打電話isPendingItem({[xindex-1]})與參數我得到的錯誤

SyntaxError: Parse error 

那麼我怎麼能在這裏傳遞參數呢?

thnx !!!

回答

2

您可以直接在if標籤內訪問內置模板變量(xindex,XCOUNT,價值觀等),所以如果你改變你的代碼去除封閉「{[]}」,那麼它應該工作:

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

沒有測試它,因爲我在我的案例中找到了一個很好的解決方法。但你的解決方案似乎是正確的。所以thanx! – headkit

相關問題