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