Click Event in a createTableViewRow
I want to have a clickable list that contain buttons/images.
My problem
- If i added Buttons in the list, it will remove the onclick event of the row.
- If i used Images as buttons, it will trigger both, the row onclick and the Image onclick.
So how can i create buttons in a list, without removing the onclick of the row. OR using images as buttons, without triggering duplicate onclick event.
2 Answers
-
when you create your row, make sure you add the selectionStyle property
var row = Ti.UI.createTableViewRow({height:60,selectionStyle:Ti.UI.iPhone.TableViewCellSelectionStyle.NONE});
Also, what I do is add a rowData property to the rows I don't want clicks on using eg:
row.noClicks = true;
Then I can check for this on the tableView click event:
if(e.rowData.noClicks==true){ break; } else { // do something based on the click on row number: e.index }
you might also be able to set touchEnabled:false in the row creation itself - but don't quote me on that ;)
-
Thanks for the reply, here is what happened.
This didn't work because i'm on Android, and this was Titanium iPhone. there was an error because of using NONE
var row = Ti.UI.createTableViewRow({height:60,selectionStyle:Ti.UI.iPhone.TableViewCellSelectionStyle.NONE});
When i tried the rest of the code, the problem still exist, i can click on buttons, but i can't click on the row.