Jquery played events

I would like to know if there is any jquery behavior that invokes lost event handlers (specifically on an iframe)?

I have a weird problem. I created a webapp consisting of two iframes. First I load the content into the first iframe. I am adding an event handler using jquery for the first content of the iframe. Everything is working. On user input, I load the page into the second iframe. This also adds some event handlers using jquery. Then a strange thing happens: jquery has lost the event handlers in the first iframe. I said "jquery lost" because if I add an event listener the old way, it's still there.

+2


source to share


2 answers


The problem has been resolved.

The problem was accessing iframe2.contentWindow

or iframe2.contentDocument

in the second iframe when the src of the second iframe was changed (the first time everything worked from the 2nd and subsequent problems) and the second frame was statically encoded in html.



To solve the problem, I always remove the second iframe and recreate and add it to the dom dynamically via javascript.

The problem only occurs in version 9.7 embedded for mips (not sure about the exact version)

+2


source


You might want to use live to bind events. This way, when you add new elements with the same selector, it will have an event associated with them.

$("p").live("click", function(){
    $(this).after("<p>Another paragraph!</p>");
});

      



Each subsequent p added to the page will have an event associated .

0


source







All Articles