Buttonbars click event listeners in tableviewrow event listeners ipad/phone

You must Login before you can answer or comment on any questions.

i have created tableview with multiple rows and added 2 tabbedbars(with 3 button objects) to each row. My problem here, when i click directly on the tabbedbar(buttons) on any one of row,for the first time tabbedbar's related event listener does not get fired. only upon second click, it used to fire.

var buttonObjects = [
    { title:'NAbutton', image:'images/na-selected.png', width:80},
    {title:'YESbutton', image:'images/yes-active.png', width:80},
    {title:'NObutton', image: 'images/no-active.png',width: 80}
];
 
var TDArray = new Array();
 
var tblSurveyDetail1 = Ti.UI.createTableView({ 
    separatorColor:'Brown',data:TDArray,top:120,height:600,width:win4.width,left:0
    ,style:Titanium.UI.iPhone.TableViewStyle.PLAIN}); 
 
 
for (var i = 0; i < 10; i++) {
 
var rowSurveyDetail = Titanium.UI.createTableViewRow({
        //backgroundImage: 'images/images-4.jpeg',
        height: 250
    });
 
var tbCompleted = Titanium.UI.createTabbedBar({
        //labels:['N/A', 'Yes', 'No'],
        labels: buttonObjects,
        index: 0,
        backgroundColor: '#ffff',
        color:'#000',
        top: 100,
        left: 160,
        style: Titanium.UI.iPhone.SystemButtonStyle.BAR,
        height: 25,
        width: 200,
        touchEnabled: true,
        zIndex:2,
 
        id: 'tbcmpltddbar' + i
    });
 
 
 
 
 
 
    var tbPictureTaken = Titanium.UI.createTabbedBar({
        labels: buttonObjects,
        index: 0,
        backgroundColor: '#fff',
        color:'#000',
        top: 160,
        left: 160,
        style: Titanium.UI.iPhone.SystemButtonStyle.BAR,
        height: 25,
        width: 200,
        zIndex:2,
 
        touchEnabled: true,
        id: 'tbbdpicbar' + i
    });
 
       rowSurveyDetail.add(tbCompleted);
    rowSurveyDetail.add(tbPictureTaken);
    //rowSurveyDetail.add(tbCompletedstaus);
 
    TDArray.push(rowSurveyDetail);
 
}
with the above lines of code , i am adding tabbedbar with buttonobjects to tableviewrows.

Below is the table's 'click' event Listener.

when i click the tabbed bar in a one of row of table it enters the tableview eventlistener and enter into the tabbedbar event listener and later clicks on the same will directly calls the tabbedbar CLICK event listener. So, is it possible to directly listen the tabbed bar CLICK event even on the first click

tblSurveyDetail1.addEventListener('click', function(e)
{
    var rowindx= e.index;
         alert(rowindx + " row selected ");
    var tbdbar=e.row.children[0];
 
    tbdbar.addEventListener('click', function(d){
 
        alert(rowindx + " row's " + d.index + " status button clicked"); 
    });
 
    var picbar=e.row.children[6];
    picbar.addEventListener('click', function(d){
 
        alert(rowindx + " row's " + d.index + " picture button clicked"); 
    });
 
});
i.e, when i click 2nd button in tabbedbar of 3rd row, above piece of code gives alert "2 row selected ",upon clicking next time it directly gives alert " 2 row's 1 picture button clicked ". what i require is on first click itself tabbedbar eventlistener should be called.

Your Answer

Think you can help? Login to answer this question!