你怎么能做到这一点?
问问题
1462 次
1 回答
1
// 此对象实现列表的 dataSource 方法。var listDataSource = {
// Sample data for the content of the list.
// Your application may also fetch this data remotely via XMLHttpRequest.
_rowData: ["Item 1", "Item 2", "Item 3"],
// The List calls this method to find out how many rows should be in the list.
numberOfRows: function() {
return this._rowData.length;
},
// The List calls this method once for every row.
prepareRow: function(rowElement, rowIndex, templateElements) {
// templateElements contains references to all elements that have an id in the template row.
// Ex: set the value of an element with id="label".
if (templateElements.label) {
templateElements.label.innerText = this._rowData[rowIndex];
}
// Assign a click event handler for the row.
rowElement.onclick = function(event) {
// Do something interesting
alert("Row "+rowIndex);
};
}
};
然后,在检查器中,将数据类型设为“动态”,标签元素将是您刚刚创建的“listDataSource”......
于 2010-01-30T22:09:26.853 回答