Hey,
i have a tableviewrow and on it there is a Button.
Now i wanna do 2 different functions, if the user presses the row or the button instead.
eventTableView.addEventListener('click', function(e) { /*Ti.App.fireEvent('app:event.select', { name:e.rowData.title }); */ var target = e.source; Ti.API.info(e.source); switch(target) { case TiUIButton: Ti.API.info("Button"); break; default: Ti.API.info("Row"); break; } });I've tried several things but nothing works... any idea?
2 Answers
Hello ,
Try this approach may this works for you :
You can, in table view event listener, check if event source is a button:
tableView.addEventListener('click', function(e) { var buttonString = e.source.toString(); if(buttonString == '[object TiUIButton]' || buttonString == '[Ti.UI.Button]') { // do work for button click } else { //do work for row click } });
you can also just assign ids to the objects like you do in HTML and check the id of the source object
var button = Titanium.UI.createButton({ title: 'Dont use toString :D', id : "row_button" }); eventTableView.addEventListener('click', function(e) { if (e.source.id === "row_button") { } })
Your Answer
Think you can help? Login to answer this question!