How do i set the id in WinJS.Binding.Template in a Win8 App

冷暖自知 提交于 2019-12-11 10:15:53

问题


The following html is not working for me.

<div id="weightListViewTemplate"  data-win-control="WinJS.Binding.Template">
<span  data-win-bind="innerText: name; id: id"></span>
</div>

<div id="basicListView" style="width:420px;height:600px"  data-win-options="{ itemTemplate: select('#weightListViewTemplate') }"
    data-win-control="WinJS.UI.ListView">
</div>

The list appears but the ID property is not set on the span objects.

How to a set the id of the span dynamically in the template based on the corresponding value in the datasource/array?


回答1:


I wouldn't recommend using the actual ID property. I believe you can't set it through data binding -- I believe WinJS uses ID's on elements under the covers to allow for weak-references to the DOM elements. Because of this it doesn't let you set the ID.

I would suggest using another property or attribute instead.



来源:https://stackoverflow.com/questions/13620411/how-do-i-set-the-id-in-winjs-binding-template-in-a-win8-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!