I am running into an issue where the search value results are not being pushed to my tableview row. I am being provided in my console that my search came back with results, but none of the results are being pushed to my label or my tableviewrow. It is probably a simple fix, but I can't seem to find the issue.
code:
function usersID(){ var Cloud = require('ti.cloud'); var findFriends = Ti.UI.createWindow({ title: 'Profile Settings', barColor:'#e67e22', backgroundColor: '#fff', navTintColor : '#fff', translucent: false }); var data = []; var searchBar = Ti.UI.createSearchBar({ top:0, height:50, showCancel: true, hintText: "Search by username" }); findFriends.add(searchBar); var noUsersFoundLabel = Ti.UI.createLabel({ text: '', top:100 }); findFriends.add(noUsersFoundLabel); searchBar.addEventListener('return', function(){ Cloud.Users.search({ q: searchBar.value }, function (e) { if (e.success) { if (e.users.length == 0){ Ti.API.info('No Users Found!'); noUsersFoundLabel.text = "No Users Found!"; data = []; } //Close nested If statement else { Ti.API.info('Success:\n' + 'Count: ' + e.users.length); noUsersFoundLabel.text = e.users.length + " Users Found!"; } //Close nested Else statement for (var i = 0; i < e.users.length; i++) { var user = e.users[i]; Ti.API.info('id: ' + user.id + '\n' + 'first name: ' + user.first_name + '\n' + 'last name: ' + user.last_name); var row = Ti.UI.createTableViewRow({ top:50, id: user.id }); var username = Ti.UI.createLabel({ text: user.username, left: 10 }); row.add(username); data.push(row); } //Close For Loop } /* Close If Statment */ else { alert('Error:\n' + ((e.error && e.message) || JSON.stringify(e))); } //Close Else Statement }); //Close function(e) }); //Close searchBar.addEventListener var tableView = Ti.UI.createTableView({ top: 50, backgroundColor:'white', data: data, search: searchBar }); findFriends.add(tableView); return findFriends; } module.exports = usersID;