2 Replies Latest reply on Nov 25, 2010 1:21 PM by Birjoy

    Adding a javascript event to a dynamically loaded content

    Birjoy

      Hello,

       

      I am new to adobe air. I am trying to create a desktop application with html and javascript. I have a page that reads data from db and lists each  records as links (a href). I need to assign an onclick event for each link.

       

      both

       

      foreach result {

           <a href="#" onclick="foo()">bla bla</a>

      }

       

      and

       

      foreach result {

           document.getElementById('container').innerHTML = '<a href="#" id="link_id">bla bloa</a>';

           document.getElementById('link_id').addEventListener("click", function() { foo(); });

      }

       

      With the second  solution it  only workd  for the last record

       

      What am I missing ?

       

      I appreciate any help.

       

      Thanks.