Skip to content

Instantly share code, notes, and snippets.

@Shadowfiend
Created June 27, 2012 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shadowfiend/3007331 to your computer and use it in GitHub Desktop.
Save Shadowfiend/3007331 to your computer and use it in GitHub Desktop.
Code to rehydrate Lift comets.
liftComet.lift_sessionLost = function() {
$('body').append(
$('<iframe src="' + location.toString() + '">')
.attr('id', 'reload-iframe')
)
var newWindow = $('#reload-iframe')[0].contentWindow
function preventInitialCometTransaction() {
if (newWindow.liftComet && typeof newWindow.liftComet.lift_cometEntry == 'function') {
liftComet.lift_cometEntry = newWindow.liftComet.lift_cometEntry;
newWindow.liftComet.lift_cometEntry = function() {}
} else {
os.nextTick(preventInitialCometTransaction)
}
}
$('#reload-iframe').load(function() {
var new_toWatch = newWindow.lift_toWatch;
newWindow.lift_toWatch = {};
var $newComets = newWindow.$('[data-lift-comet]')
$('[data-lift-comet]').each(function(i) {
this.outerHTML = $newComets[i].outerHTML;
})
lift_toWatch = new_toWatch;
liftComet.lift_handlerSuccessFunc();
})
$('#reload-iframe').remove();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment