我想知道如何在Kendo mobile ListView中获取所选项目的索引.这是我的代码
function loadInformation(){
$('#Template').kendoMobileListView({
dataSource: Info,
template: '<table style="width: 100%"><tr><td><p>${a = (typeof data.ServiceLocationCompanyName !== "undefined") ? data.ServiceLocationCompanyName : data.LastName + ", " + data.FirstName}</td><td style="width: 84px"><img src=${data.Icon} /></td></tr></table>',
// Added this event to capture the index of selected Item but was unsuccessful
click: function(){
var index = this.select().index(),
console.log(index);
}
});
Run Code Online (Sandbox Code Playgroud)
当我运行它时,它给我一个错误说
TypeError: Object [object Object] has no method 'select'
Run Code Online (Sandbox Code Playgroud)
我需要做什么?如何获取所选项目的索引?干杯
尝试一下这个:
function loadInformation(){
$('#Template').kendoMobileListView({
dataSource: Info,
template: '<table style="width: 100%"><tr><td><p>${a = (typeof data.ServiceLocationCompanyName !== "undefined") ? data.ServiceLocationCompanyName : data.LastName + ", " + data.FirstName}</td><td style="width: 84px"><img src=${data.Icon} /></td></tr></table>',
// Added this event to capture the index of selected Item but was unsuccessful
click: function(e){
var index = $(e.item).index();
var text = $(e.item).text();
console.log('selected item contains text: ',text,' and its index is: ',index);
}
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10313 次 |
| 最近记录: |