This is a migrated thread and some comments may be shown as answers.

ListView: Uncaught TypeError: Cannot read property 'apt' of undefined

1 Answer 281 Views
ListView (Mobile)
This is a migrated thread and some comments may be shown as answers.
steve
Top achievements
Rank 1
steve asked on 06 Oct 2012, 03:33 PM
I am trying to start with an initial list of items and display them using the mobile listview. This works fine, however if I add to the list and re-display the items, then the click event can no longer find the data property and throws an error. Here is the code, any help or suggestions on how to do this is appreciated.

var aptdata = [
            { 'apt': 'ATL', 'name': 'Atlanta' },
            { 'apt': 'JFK', 'name': 'John F Kennedy' },
            { 'apt': 'LGA', 'name': 'La Guardia' }
];

function alistbind() {
    var ldata = localStorage.aptdata;
    if (ldata == null) {
        localStorage.aptdata = JSON.stringify(aptdata);
    }
    $("#alist").kendoMobileListView({
        autoBind: false,
        dataSource: JSON.parse(localStorage.aptdata),
        style: 'inset',
        template: "<a>${apt} - ${name}</a>",
        click: function (e) {
            console.log('fun clicked: ' + e.dataItem.apt);
            showdetail(e.dataItem.apt);
            app.navigate("#aptdetail");
        }
    });
    $("#alist").data("kendoMobileListView").dataSource.read();
}

function AddAirport() {
    var ldata = JSON.parse(localStorage.aptdata)
    var newapt = { 'apt': 'FLL', 'name': 'Ft Lauderdale' };
    ldata.push(newapt);
    localStorage.aptdata = JSON.stringify(ldata);
    alistbind();
}

1 Answer, 1 is accepted

Sort by
0
Juan Carlos
Top achievements
Rank 1
answered on 09 Nov 2012, 08:04 PM
Did you find the solution??
I´m having same problem.
Tags
ListView (Mobile)
Asked by
steve
Top achievements
Rank 1
Answers by
Juan Carlos
Top achievements
Rank 1
Share this question
or