View Full Version : addlistener stops working

8 Jan 2007, 8:59 PM
I have an addlistener which listens for a keyup in a text box and it works well until I click a link which calls a new connectionWrapper. The connectionWrapper reloads the div that houses the text box that the listener listens to. Once the connectionWrapper is called, the addlistener stops working. Do you have any idea why this is and how I can get the addlistener to continue working properly even after the link is clicked.

Thanks in advance for the help.

8 Jan 2007, 9:12 PM
If you're overwriting the div with new content, even if it's the same HTML, you're still creating new DOM objects. You will need to rewire your events to the new elements. Or don't overwrite the entire div - update an element inside the div (e.g text above/below the textarea), but leave the textarea alone.

8 Jan 2007, 9:24 PM
Thanks for the quick reply but I have to admit, I am new to javascript and didn't quite catch all of what you explained. Can you tell me how I could "rewire" the events. I just don't know what changes once the div is reloaded. The id of the textbox is still the same and the event listener is created in the main page, not the reloaded page.

Thanks again.

9 Jan 2007, 1:08 AM
The id may be the same, but it's a different, new object, you'll have to set up the listeners again.