Project: titanium
Issue TIMOB-20619: Windows: App crash on click eventlistener of appended row of tableview
I have a table view and I am appending rows to it. When I click the default values of the table, the click listener is working fine but when I try to click the appended row item, it is exiting the app without any error or log. I have tried adding the event listener to the append row separately but it is also not working. Below is my code {code:java} var args = arguments[0] || {}; var toastMsg = require('toastMessage'); //var limit = 10 ; $.topView.headerLabel.text = "MESSAGES"; //$.topView.menuListImgRight.image = "images/icons/internalScreenIcons/search.png"; var lastPostId; var allLoaded = false; var sectionVal = 0; var messageRefresh = function(e) {	listMessage(); }; Ti.App.addEventListener("messageRefresh", messageRefresh); var TimelineMessageRefresh = function(e) {	listMessage(); }; $.getNext.addEventListener('click', function(e) {	nextTen(Ti.App.Properties.getString('postid')); }); Ti.App.addEventListener("TimelineMessageRefresh", TimelineMessageRefresh); //if (Alloy.Globals.offlineDetect()) { if (Ti.Network.networkTypeName == Ti.Network.NETWORK_NONE || Ti.Network.networkTypeName == Ti.Network.NETWORK_UNKNOWN) {	Ti.API.info("offline ");	offlineList(); } else {	Ti.API.info("online messagelist");	listMessage(); } function listMessage() {	var data = [];	Ti.API.info("Called " + lastPostId);	var tableData = [];	var session = Ti.App.Properties.getString('sessionId');	var userid = Ti.App.Properties.getString('userId');	var _usergroup = [];	var _ug = "?limit=0";	for ( i = 0; i < Alloy.Globals.userGroup.length; i++) {	_usergroup.push(Alloy.Globals.userGroup[i]);	}	for (var i = 0; i < _usergroup.length; i++) {	_ug = _ug + "&userGroup=" + _usergroup[i];	Ti.API.info("UG: " + _ug);	if (i == _usergroup.length - 1) {	var url = Alloy.CFG.api.base + Alloy.CFG.api.post + "?limit=0&postType=1";	var response;	var xhr = Ti.Network.createHTTPClient({	onload : function() {	// handle the response	try {	response = this.responseText;	//Ti.API.info("Response: " + response);	var _response = JSON.parse(response);	Ti.API.info("_response 11 : " + JSON.stringify(_response, null, 2));	for (var i = 0; i < _response.length; i++) {	Ti.App.Properties.setString('postid', _response[i].id);	var row = Ti.UI.createTableViewRow({	height : '120dp'	//top : "50dp"	});	var imgView = Ti.UI.createImageView({	width : "45dp",	height : "45dp",	left : "15dp",	top : "10dp",	image : "images/icons/homeScreenIcons/ViewResponses.png"	});	var container = Ti.UI.createView({	left : "20%",	layout : "vertical"	});	var title = Ti.UI.createLabel({	text : _response[i].post,	font : {	fontFamily : "Century Gothic",	fontWeight : "Bold",	fontSize : "18dp"	},	color : "#d01227",	left : '0%',	width : '90%',	height : '30%',	top : "10dp"	});	var sendTo = Ti.UI.createLabel({	text : "Sent to: " + _response[i].sendTo,	font : {	fontFamily : "Century Gothic",	fontWeight : "Normal",	fontSize : "14dp"	},	color : "#999999",	top : '5dp',	left : '0dp',	width : '90%',	height : '16dp'	});	var date = Ti.UI.createLabel({	text : _response[i].updatedAtDate,	font : {	fontFamily : "Century Gothic",	fontWeight : "Normal",	fontSize : "14dp"	},	color : "#999999",	top : '6dp',	left : '0dp'	});	var border = Ti.UI.createView({	height : "2dp",	top : "110dp",	backgroundColor : "red",	width : "80%"	});	var commentCount = Ti.UI.createLabel({	text : _response[i].commentCount + " comments",	color : "#999999",	bottom : '10%',	right : '10%',	font : {	fontFamily : "Century Gothic",	fontWeight : "Normal",	fontSize : "14dp"	}	});	container.add(title);	container.add(sendTo);	container.add(date);	row.add(container);	row.add(imgView);	row.add(border);	row.add(commentCount);	//row.postType = _response[i].postType;	row.id = _response[i].id;	row.info = _response[i].sendTo;	row.name = _response[i].post;	row.date = _response[i].updatedAtDate;	row.comments = _response[i].commentCount;	tableData.push(row);	}	$.table.data = tableData;	//Ti.API.info('messageDb:' + JSON.stringify(Alloy.Collections.messageDb.toJSON(), null, 2));	} catch(e) {	alert(e);	}	},	onerror : function(e) {	Ti.API.info(e.code);	if (e.code == 401) {	Alloy.createController('login/login').getView().open();	//$.messageList.close();	}	////alert(e.code);	}	});	xhr.open('GET', url);	xhr.setRequestHeader("x-access-token", session);	xhr.setRequestHeader("deviceid", encrypt("c3ff7453a0b44a69"));	xhr.setRequestHeader("userid", encrypt(userid));	//xhr.setRequestHeader("Content-Type", "application/json");	xhr.send();	}	} } $.table.addEventListener('click', function(e) {	Ti.API.info("onclick msg : " + JSON.stringify(e));	var data = {	name : e.row.name,	info : "Sent to : " + e.row.info,	date : e.row.date,	id : e.row.id,	comments : e.row.comments + " comments"	};	Ti.API.info("name 1 : " + JSON.stringify(e.row.name));	Ti.API.info("date 1 : " + JSON.stringify(e.row.date));	Ti.API.info("info 1 : " + JSON.stringify(e.row.info));	Ti.API.info("id 1 : " + JSON.stringify(e.row.id));	Alloy.createController('viewResponse/commentList', data).getView().open(slide_it_left);	//$.messageList.close(); }); function nextTen(lastPostId) {	var data = [];	var tableData = [];	var session = Ti.App.Properties.getString('sessionId');	var userid = Ti.App.Properties.getString('userId');	var _usergroup = [];	var _ug = "?limit=" + lastPostId;	for ( i = 0; i < Alloy.Globals.userGroup.length; i++) {	_usergroup.push(Alloy.Globals.userGroup[i]);	}	for (var i = 0; i < _usergroup.length; i++) {	_ug = _ug + "&userGroup=" + _usergroup[i];	Ti.API.info("UG: " + _ug);	if (i == _usergroup.length - 1) {	var url = Alloy.CFG.api.base + Alloy.CFG.api.post + "?limit=" + lastPostId + "&postType=1";	var response;	var xhr = Ti.Network.createHTTPClient({	onload : function() {	// handle the response	response = this.responseText;	//Ti.API.info("Response: " + response);	var _response = JSON.parse(response);	Ti.API.info("_response 22 : " + JSON.stringify(_response, null, 2));	if (_response.length > 0) {	for (var i = 0; i < _response.length; i++) {	Ti.App.Properties.setString('postid', _response[i].id);	var row = Ti.UI.createTableViewRow({	height : '120dp'	//top : "50dp"	});	var imgView = Ti.UI.createImageView({	width : "45dp",	height : "45dp",	left : "15dp",	top : "10dp",	image : "images/icons/homeScreenIcons/ViewResponses.png"	});	var container = Ti.UI.createView({	left : "20%",	layout : "vertical"	});	var title = Ti.UI.createLabel({	text : _response[i].post,	font : {	fontFamily : "Century Gothic",	fontWeight : "Bold",	fontSize : "18dp"	},	color : "#d01227",	left : '0%',	width : '90%',	height : '30%',	top : "0dp"	});	var sendTo = Ti.UI.createLabel({	text : "Sent to: " + _response[i].sendTo,	font : {	fontFamily : "Century Gothic",	fontWeight : "Normal",	fontSize : "14dp"	},	color : "#999999",	top : '5dp',	left : '0dp',	width : '90%',	height : '16dp'	});	var date = Ti.UI.createLabel({	text : _response[i].updatedAtDate,	font : {	fontFamily : "Century Gothic",	fontWeight : "Normal",	fontSize : "14dp"	},	color : "#999999",	top : '6dp',	left : '0dp'	});	var border = Ti.UI.createView({	height : "2dp",	top : "115dp",	backgroundColor : "red",	width : "80%"	});	var commentCount = Ti.UI.createLabel({	text : _response[i].commentCount + " comments",	color : "#999999",	bottom : '10%',	right : '10%',	font : {	fontFamily : "Century Gothic",	fontWeight : "Normal",	fontSize : "14dp"	}	});	container.add(title);	container.add(sendTo);	container.add(date);	row.add(container);	row.add(imgView);	row.add(border);	row.add(commentCount);	//row.postType = _response[i].postType;	row.id = _response[i].id;	row.name = _response[i].post;	row.info = _response[i].sendTo;	row.date = _response[i].updatedAtDate;	row.comments = _response[i].commentCount;	tableData.push(row);	row.addEventListener('click', function(e) {	Ti.API.info("onclick inside nextten msg : " + JSON.stringify(e));	var data = {	name : e.row.name,	info : e.row.info,	date : e.row.date,	id : e.row.id,	comments : e.row.comments + " comments"	};	Ti.API.info("name 1 : " + JSON.stringify(e.row.name));	Ti.API.info("date 1 : " + JSON.stringify(e.row.date));	Ti.API.info("info 1 : " + JSON.stringify(e.row.info));	Ti.API.info("id 1 : " + JSON.stringify(e.row.id));	Alloy.createController('viewResponse/commentList', data).getView().open(slide_it_left);	//$.messageList.close();	alert("inside row onclick");	});	}	$.table.appendRow(tableData);	} else {	allLoaded = true;	}	},	onerror : function(e) {	Ti.API.info(e.code);	if (e.code == 401) {	Alloy.createController('login/login').getView().open();	//$.messageList.close();	}	////alert(e.code);	}	});	xhr.open('GET', url);	xhr.setRequestHeader("x-access-token", session);	xhr.setRequestHeader("deviceid", encrypt("c3ff7453a0b44a69"));	xhr.setRequestHeader("userid", encrypt(userid));	//xhr.setRequestHeader("Content-Type", "application/json");	xhr.send();	}	} } {code}
Story points: 5