如何获取 TemplateCollectionView 中的索引?
所以我按照sproutcore“入门”指南,开始偏离路径,看看我是否可以轻松地实现我的意思。我在这里使用这个模板,它代表文件输入列表:
{{#collection SC.TemplateCollectionView
contentBinding="Upload.uploadListController"}}
<label>{{content.title}}</label><input type="file" name="upload[]"/>
{/collection}}
很好。现在我想做的是受益于标签 for
属性来指向相应的输入。基本上,我想输出这样的内容:
<label for="upload-0">Some label</label>
<input id="upload-0" type="file" name="upload[]"/>
<label for="upload-1">Some otherlabel</label>
<input id="upload-1" type="file" name="upload[]"/>
<!-- you get it -->
我该怎么做?我在 使用车把页面 和 SC.ArrayController 上的 sproutcore 文档
我看错了吗 地方?我是否正在尝试以另一种更类似芽核的方式做一些我应该做的事情?
So I followed the sproutcore "getting started" guide, and started wandering off the path to see if I could do what I meant easily. And here I am witht this templates, that represents a list of file inputs :
{{#collection SC.TemplateCollectionView
contentBinding="Upload.uploadListController"}}
<label>{{content.title}}</label><input type="file" name="upload[]"/>
{/collection}}
Nice. Now what I'd like to do is benefit from the label for
attribute to point to the corresponding input. So basically, I'd like to output something like this:
<label for="upload-0">Some label</label>
<input id="upload-0" type="file" name="upload[]"/>
<label for="upload-1">Some otherlabel</label>
<input id="upload-1" type="file" name="upload[]"/>
<!-- you get it -->
How do I do that? I did not find the answer neither on the using handlebars page nor on the sproutcore documentation on SC.ArrayController
Am I looking in the wrong place? Am I trying to do something I should do in another, more sproutcore-ish way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为做到这一点的唯一方法是在模型中添加一个 id 字段。
所以你可以在模板中使用这个 id。
The only way I see to do this is adding an id field in your model.
So you could use this id in the template.