simulate button click / touch
i have a tableview that has a child. it opens a new window for edit. once the record is updated i would like to simulate a click of the leftnavbutton to go back to the previous window. any help on this would be great.
3 Answers
-
Accepted Answer
Hi there.
Titanium.UI.currentWindow.close();
should do it.cheers,
Chris. -
I have tried that, but the whole application closes. The following line is in the console.
[DEBUG] Session did end with error (null) [INFO] Application has exited from Simulator
Here is what I have, I have a tabGroup with 2 tabs.
var win2 = Ti.UI.createWindow({ url:'main_windows/request_list.js', title:'Request List' });
on the request_list.js i create a tableview that the rows have detail
var icnt = 0; while (rows.isValidRow()) { // Ti.API.info("record status: " + rows.getfieldByName('RECORD_STATUS')); // Titanium.API.info("counter: " + icnt); var tableId = rows.fieldByName('ID'); var tvr = Ti.UI.createTableViewRow({hasDetail:true, title:rows.fieldByName('ENTRY_TEXT')}); //tvr.add(Label); tvr.tableId = tableId; data[icnt] = tvr; rows.next(); icnt++; } //Ti.API.debug(data); rows.close(); tv.setData(data);
then i have an eventListener on the on the tableview for the click event
tv.addEventListener ('click', function(e) { // SHOW DETAIL FROM SELECTED ROW if (e.row.hasDetail) { // open a detail window var win1 = Ti.UI.createWindow({url:'request_detail.js'}); Ti.API.info(e.rowData.tableId); // provide access to this row's data win1.rowData = e.rowData; Ti.UI.currentTab.open(win1); } });
in request_detail.js: i get the current window and listen for a button click
// GRAB CURRENT WINDOW var win = Ti.UI.currentWindow; .... btn1.addEventListener('click', function() { Ti.API.info("Update Request"); Ti.API.info("length of value: " + ta1.value.trim().length); if (ta1.value.trim().length > 0) { // GET THE CURRENT ID # var nextID = row.getFieldByName('ID'); // UPDATE THE RECORD TO THE DB db.execute('UPDATE REQUESTS SET ENTRY_TEXT = ? WHERE ID =?', ta1.value, nextID); // SHOW NEW VIEW :: REQUEST LIST win.close(); });
When it hits that last line in the listener then the whole application closes with the error above.
-
never mind i changed some code around and now everything is working.