Ticket #10881 (closed bug: invalid)
Cannot place $.clone'd element into DOM using $.html more than once
|Reported by:||benno_007||Owned by:|
If you store a cloned DOM element in a variable, you can only put it back in the DOM once, using $.html(). If you try to put it back in a second time, the events are lost
Test case: http://jsfiddle.net/benno_007/Pasge/.
Click the text to see the event, after 4 seconds it'll replace the content again. The events will be gone.
Scenario: Generate 'A' as a dynamic DOM element with bound events. Then you replace that with 'B' and generate similar to A but with different events targetting different elements. It then replaces B with A using $('body').html(clonesA). This works (events, content). Then we do $('body').html(clonesB). This works (events, content). Then we do $('body').html(clonesA) again, and the events have been lost but the content is still there.
Using this to generate banners on my site with actions, and trying to cache the elements and their events in variables, but can't because it doesn't work the second time around. Using $.live instead of bind works, but the events appear to apply to ALL banners.