I'm developping a small web client application using jquery
The App at the first page of session contains only the app menu which trigger ajax requests, display data received in a new tab (within the page) and set event handlers via callbacks.
When the user have more than one tab opened, the tab(s) not focused are detached from the DOM using $(tab).detach(), & the returned object is stored in an array until the tab regain focus (object is then append back to the DOM).
The magic of detach is that the object returned contains all the event handlers bind to all the html elements within (so when we append it back we don't have to rebind nothing) Which is great&fast, except that i cannot manage to serialize that object (and store it to recover the tabs opened when the user is browsing on a different page of the site). I could find the html, but the event handlers ... ?
$panels.panel[el]=$("#"+el).detach();
alert(itobj($panels.panel[el])); //-> key: 0 value: [object HTMLDivElement]
alert($panels.panel[el].html()); //-> return the innerhtml
sessionStorage.setItem(el,$.toJSON($panels.panel[el]));
alert(sessionStorage.getItem(el)); //-> {"length":1,"0":{},"context":{"jQuery17204145571568968498":1,"location":{}},"selector":"#panelid"}
So how could those event handlers be recovered by the session ? does it have anything to do with the context ? Or is there a better way to serialize (have been using toJSON from : http://code.google.com/p/jquery-json/ )?
Any help very appreciated, so thanks a tun (the idea of keeping track of all the callbacks to recall them is highly depressing - & making useless the magic of detach)