Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

tableView

I have a tableview on which i attach a click event, but when i click on a row this event is being called many times (like 5 or 10). What am i doing wrong or how could i fix this. Here is the attachevent part of the code:

tableView.addEventListener('click',function(e) {
            iNieuwsIndex = e.row.className.substring(13);
            Titanium.API.info('Gebruiker heeft geklikt op element nummer: ' + iNieuwsIndex);

            // Nieuw window aanmaken

            var nieuwsDetailWindow = Titanium.UI.createWindow({
                title:nieuwsberichten[iNieuwsIndex].titel,
                backgroundColor:"#10193e",
                url:'window_nieuws_detail.js',
                nieuwsberichtObj:nieuwsberichten[iNieuwsIndex]
            });

            Titanium.UI.currentTab.open(nieuwsDetailWindow);    
        });
— asked November 15th 2010 by Jeroen van Gijzel
  • click
  • event
  • eventlistener
  • tableview
2 Comments
  • There doesn't seem to be anything wrong with your event listener as long as this is not wrapped in a for loop?. Can you post more of the tableView code?

    — commented November 15th 2010 by Roger Chapman
  • Well, i'm sorry guys. I found the solution:
    Everytime when i reloaded the data i attached the eventlistener.

    Solution:
    Attach eventlistener once after creating tableview for the first time.

    — commented November 15th 2010 by Jeroen van Gijzel

0 Answers

The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.