what happens to window events when changing documents? what happens to window events when changing documents? jquery jquery

what happens to window events when changing documents?


Well, in the end i discovered that all though you only change document, window events gets deleted as they lay inside the document.

I encoutred my problems with History.js i think because the fact that im changing documents break it at some point.

What i did was use native HTML5 history API and rebinded the popstate event in the new document.


have you tried to bind the element with LIVE ?

$(element).click(function(e){    e.preventDefault();    //more code    History.pushState({file : file},title, fullHref);});

becomes

$(element).live('click',function(e){        e.preventDefault();        //more code        History.pushState({file : file},title, fullHref);    });


You have to use iframe to load your document and easily can change its document. Then, you can listen for a click event like this,

$("#iframe").load(function () {    $(this.contentWindow).click(function () {        // do your click events here    });});

The iframe will reload if you change the src attribute value as another document.