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

2 posts, 0 answers
  1. steve
    steve avatar
    2 posts
    Member since:
    Aug 2006

    Posted 06 Oct 2012 Link to this post

    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();
    }
  2. Juan Carlos
    Juan Carlos avatar
    8 posts
    Member since:
    Oct 2012

    Posted 09 Nov 2012 Link to this post

    Did you find the solution??
    I´m having same problem.
  3. Kendo UI is VS 2017 Ready
Back to Top