2

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);        
    }
});

これを実行すると、エラーが表示されます

TypeError: Object [object Object] has no method 'select'

ここで何をする必要がありますか? 選択したアイテムのインデックスを取得するにはどうすればよいですか? 乾杯

4

1 に答える 1

5

これを試してみてください:

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);        
        }
    });
}
于 2012-09-11T21:19:44.337 に答える