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);
            autoBind: false,
            dataSource: JSON.parse(localStorage.aptdata),
            style: 'inset',
            template: "<a>${apt} - ${name}</a>",
            click: function (e) {
                console.log('fun clicked: ' + e.dataItem.apt);

    function AddAirport() {
        var ldata = JSON.parse(localStorage.aptdata)
        var newapt = { 'apt': 'FLL', 'name': 'Ft Lauderdale' };
        localStorage.aptdata = JSON.stringify(ldata);
  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.
Back to Top