【问题标题】:sencha touch :: how to pass index-Id from list into XTemplate functionsencha touch :: 如何将 index-Id 从列表传递到 XTemplate 函数
【发布时间】:2011-10-03 16:27:44
【问题描述】:

我想用 XTemplates 创建一个动态变化的列表。难受。您不能通过 if 结构中的函数传递 index-id,例如

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

那么我怎么能在这里传递参数呢?

谢谢!!!

【问题讨论】:

    标签: list templates sencha-touch arguments


    【解决方案1】:

    您可以直接在 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>';
    

    【讨论】:

    • 没有测试它,因为我在我的案例中找到了一个很好的解决方法。但您的解决方案似乎是正确的方法。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多