Results 1 to 2 of 2
Oct 29, 2007, 12:09 #1
- Join Date
- Oct 2007
- 0 Post(s)
- 0 Thread(s)
I have PHP file called file1.php with an empty <div></div> in the middle. I've added a 'load' event listener so that on page load, it calls an AJAX function that calls file2.php. file2.php creates a table and loads it into the <div></div> in file1.php.
file2.php has <a> tags in it's <th> columns and I wish to trap when a user clicks on the column heading. The old way was to use the onclick() method but I'd rather use event listeners.
Here's my problem. I am getting "obj has no properties" when trying to add those listeners. I *think* it is because the code in file2.php isn't part of the original DOM tree for file1.php. So how can I use event listeners instead of onlclick()? I know I can add top the DOM by creating elements and appending them but that adds to the HTML code and my code is already in place via the AJAX call.
What to do...? DO I just use the old passe onclick() method?
Oct 30, 2007, 22:59 #2
It sounds like you're trying to attach the events before the content of the div has arrived. Once it's there it will definitely be part of the DOM tree.