Listening cleared?

Listening cleared?

by Kevin Burton -
Number of replies: 0

This is a little complicated to explain the problem so please bear with me. 

As part of a page I call $PAGE->requires->yui_module(....

As part of the 'init' function I do Y.delegate('click', function(e) {. . . .), '#id_search_results', 'img'). So this function gets executed whenever a click event occurs on an 'img' element inside the container identified by '#id_search_results'. As the name implies this requires an id_search_results container and some 'img' elements within it. These are not available when the page loads. However when a search is done then there is a container with some 'img' elements in it. When I click on the images I get what I expect (the first time). So I do another search. This clears out the container and replaces the 'img' elements with 'img' elements that coorespond to the new search. Again this works as expected. But, when I click on any of the 'img' elements I don't get a response. It is as if the listener has been turned off. Is this expected? How to I 'reset' the listener so it handles the click event again? Is it as simple as reissueing the Y.delegate call? Am I going to run into trouble with multiple of the 'same' handler not getting cleaned up properly? Thank you.

Average of ratings: -